/*
 * MainScreenPanel.java
 *
 * Created on Nov 30, 2009, 6:56:36 PM
 * @author Tim Pruitt
 */

package hirt;

import java.awt.Color;
import java.awt.Component;
import java.awt.Point;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.MenuItem;
import java.awt.event.KeyEvent;
import java.util.LinkedList;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.DefaultListModel;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;



/**
 * The GUI of HIRT.
 * @author Tim Pruitt
 */
public class MainScreenPanel extends javax.swing.JPanel
{
    /**
     * The string for adding a role.
     * Used for responderButton text to dictate adding a role.
     *
     * @author: Tim Pruitt
     *
     * @see DROP_ROLE
     * @see playOrStopRole
     */
    private static final String ADD_ROLE = "Play";

    /**
     * The string for dropping a role.
     * Used for responderButton text to dictate dropping a role.
     *
     * @author: Tim Pruitt
     *
     * @see ADD_ROLE
     * @see playOrStopRole
     */
    private static final String DROP_ROLE = "Stop";

    /**
     * The color of an editable control.
     * @author Tim Pruitt
     */
    private static final Color EDITABLE_COLOR = Color.white;

    /**
     * The array of items our project wishes to implement
     * @author Tim Pruitt
     */
    private static final int VEHICLE_ITEMS[] = {
        ServerConstants.CONE,
        ServerConstants.SIGN,
        ServerConstants.DRUM,
        ServerConstants.FLARE
    };

    /**
     * The total number of responders used in the GUI
     *
     * @author Tim Pruitt
     */
    private static final int RESPONDER_COUNT = Role.NUMBER_OF_ROLES;

    /**
     * The Item2D that is right-clicked on.
     *
     * @author Tim Pruitt
     *
     * @see getRightClickedItem()
     * @see handleSceneClick(Item2D item)
     */
    private Item2D rightClickedItem;

    /**
     * The session this MainScreenPanel is associated with.
     *
     * @author Tim Pruitt
     *
     * @see setSession(Session session)
     * @see HirtClient.getSession()
     */
    protected Session session;

    /**
     * This is a reference to the player local to this program/computer.
     *
     * @author Tim Pruitt
     *
     * @see getLocalPlayer
     */
    protected Player localPlayer;

    /**
     * This is a reference to the network client object.
     *
     * @author Tim Pruitt
     *
     * @see getClient()
     */
    protected HirtClient client;

    /**
     * This is the overarching parenting JFrame.
     *
     * @author Tim Pruitt
     */
    MainFrame mainFrame;

    /**
     * The JPopupMenu associated with a right-click.
     *
     * @author Tim Pruitt
     *
     * @see handleSceneClick(Item2D item)
     */
    ScenePopupMenu popupRightClick;

    /**
     * The x-coordinate of the cursor at the right-clicking instance.
     *
     * @author Tim Pruitt
     *
     * @see getRightClickX()
     * @see handleSceneClick(Item2D item)
     * @see rightClickY
     */
    private int rightClickX;

    /**
     * The y-coordinate of the cursor at the right-clicking instance.
     *
     * @author Tim Pruitt
     *
     * @see getRightClickY()
     * @see handleSceneClick(Item2D item)
     * @see rightClickX
     */
    private int rightClickY;

    // TODO Tim2Andrew implement when dragging, this member is set to true, false when not
    boolean dragging = false;
    Point dragOrigin = new Point( 0,0 );
    Point dragDelta = new Point( 0,0 );
    Point dragEndPoint = new Point( 0,0 );

    /**
     * The JLabel array that displays every responder's name.
     * Is blank if responder is not being played by a user.
     *
     * @author Tim Pruitt
     *
     * @see setResponderNames()
     * @see responderButton
     * @see responderLabel
     */
    JLabel[] responderName = new JLabel[RESPONDER_COUNT];

    /**
     * The button array in the Responder Window that gives various options:
     *  Adding the role if no one is playing it, Dropping the role if you are
     *  playing it, and invisible if someone else is playing it.
     *
     * @author Tim Pruitt
     *
     * @see refreshResponders()
     */
    JButton[] responderButton = new JButton[RESPONDER_COUNT];

    /**
     * The JLabel array that displays the responder type.
     *
     * @author Tim Pruitt
     *
     * @see refreshResponders()
     */
    JLabel[] responderLabel = new JLabel[RESPONDER_COUNT];

    /**
     * The JLabel array that displays the item icons.
     *
     * @author Tim Pruitt
     *
     * @see setItemEnabling(int itemIndex, boolean enabling)
     */
    JLabel[] itemLabels = new JLabel[VEHICLE_ITEMS.length];

    /**
     * The JLabel array that displays the item types
     *
     * @author Tim Pruitt
     *
     * @see refreshItems()
     * @see setItemEnabling(int itemIndex, boolean enabling)
     */
    JLabel[] itemNames = new JLabel[VEHICLE_ITEMS.length];

    /**
     * The JTextField array that displays the item counts.
     * In editor mode, it's editable, strictly displaying if not.
     *
     * @author Tim Pruitt
     */
    JTextField[] itemCounts = new JTextField[VEHICLE_ITEMS.length];

    /**
     * This is a temporary angle that is used for rotating a vehicle.
     *
     * @author Tim Pruitt
     */
    private float tempAngle;


    /**
     * Creates new form MainScreenPanel.
     * 
     * @author Tim Pruitt
     * 
     * @param client The local client for new MainScreenPanel.
     */
    public MainScreenPanel( HirtClient client )
    {
        initComponents();
        setVisible( true );

        // Set all the globals
        this.client = client;
        this.mainFrame = client.getGUI();
        session = client.getSession();            // Very important.
        localPlayer = client.getLocalPlayer();    // Very important.
        
        //TODO Client should check and see what player Type is
        localPlayer.setType(Player.TYPE_INSTRUCTOR);

        // Set the Responder Names
        responderName[0] = this.lblResponder3;
        responderName[1] = this.lblResponder2;
        responderName[2] = this.lblResponder1;
        responderName[3] = this.lblResponder4;
        responderName[4] = this.lblResponder5;
        responderName[5] = this.lblVictimName;

        // Set the Responder Buttons
        responderButton[0] = this.btnEmsResponder;
        responderButton[1] = this.btnFireResponder;
        responderButton[2] = this.btnPoliceResponder;
        responderButton[3] = this.btnIdotResponder;
        responderButton[4] = this.btnTowResponder;
        responderButton[5] = this.btnVictimResponder;

        // Set the Responder Labels
        responderLabel[0] = this.lblEMS;
        responderLabel[1] = lblFire;
        responderLabel[2] = lblPolice;
        responderLabel[3] = lblIDOT;
        responderLabel[4] = lblTow;
        responderLabel[5] = this.lblVictim;

        // Set the Item Icons
        itemLabels[0] = this.item0Label;
        itemLabels[1] = this.item1Label;
        itemLabels[2] = this.item2Label;
        itemLabels[3] = this.item3Label;

        // Set the Item Names
        itemNames[0] = this.lblItem0Name;
        itemNames[1] = this.lblItem1Name;
        itemNames[2] = this.lblItem2Name;
        itemNames[3] = this.lblItem3Name;

        // Set the Item Counts
        itemCounts[0] = this.lblItem0Count;
        itemCounts[1] = this.lblItem1Count;
        itemCounts[2] = this.lblItem2Count;
        itemCounts[3] = this.lblItem3Count;

        refreshMainScreen();
        setEditables( client.getSession().getMode() );
        setButtonEnables();
        createRequestVehicle();

        displayDirections( Feedback.WELCOME );
    }

    /**
     * Displays the specific direction in the lblDirections component.
     *
     * @author Tim Pruitt
     *
     * @param text What is needed to be displayed.
     */
    public void displayDirections(int directionIndex) {
        lblDirections.setText( Feedback.DIRECTIONS[directionIndex] );
    }

    /**
     * Populates the comboRequest box with the needed vehicles able to be
     *  requested.
     *
     * @author Tim Pruitt
     *
     * @see comboRequest
     */
    private void createRequestVehicle() {
        comboRequest.removeAll();
        comboRequest.removeAllItems();
        
        comboRequest.addItem(GUIPrompts.REQUEST_VEHICLE);

        String vehicleNames[] = Role.ROLE_VEHICLE_NAMES;
        for (int index = 0; index < vehicleNames.length; index++) {
            comboRequest.addItem( "Request " + vehicleNames[index] );
        }

        if (comboRequest.getSelectedIndex() == 0) {
            btnSendRequest.setEnabled(false);
        }
    }

    /**
     * Depending on what the mode is, it sets certain controls to either
     *  editable or not.
     *
     * @author Tim Pruitt
     *
     * @param mode
     */
    private void setEditables(int mode) {
        switch (mode) {
            case Session.MODE_REVIEW:
                this.lblDescription.setEditable(false);
                this.lblDescription.setOpaque(false);

                this.txtScenarioName.setEditable(false);
                this.txtScenarioName.setOpaque(false);

                for (int index = 0; index < itemCounts.length; index++) {
                    itemCounts[index].setEditable(false);
                    itemCounts[index].setOpaque(false);
                }
                
                comboRequest.setVisible(false);

                break;
            case Session.MODE_PLAY:
                this.lblDescription.setEditable(false);
                this.lblDescription.setOpaque(false);

                this.txtScenarioName.setEditable(false);
                this.txtScenarioName.setOpaque(false);

                for (int index = 0; index < itemCounts.length; index++) {
                    itemCounts[index].setEditable(false);
                    itemCounts[index].setOpaque(false);
                }

                comboRequest.setVisible(true);

                break;
            case Session.MODE_EDITOR:
                this.lblDescription.setEditable(true);
                this.lblDescription.setOpaque(true);
                this.lblDescription.setBackground(EDITABLE_COLOR);

                this.txtScenarioName.setEditable(true);
                this.txtScenarioName.setOpaque(true);
                this.txtScenarioName.setBackground(EDITABLE_COLOR);

                for (int index = 0; index < itemCounts.length; index++) {
                    itemCounts[index].setEditable(true);
                    itemCounts[index].setOpaque(true);
                    itemCounts[index].setBackground(EDITABLE_COLOR);
                }

                comboRequest.setVisible(false);

                break;
            default:
                System.out.println("setEditables(int mode): cannot read the mode.");
        }
    }

    /**
     * setSession links the main working screen to an existing Session.
     * @author adieffe
     */
    public void setSession( Session session )
    {
        this.session = session;
        refreshMainScreen();
    }

    /**
     * @author Tim Pruitt
     *
     * @return the local localPlayer
     */
    public Player getLocalPlayer() {
        return client.getLocalPlayer();
    }

    /**
     * @author Tim Pruitt
     * @return The local client
     */
    public HirtClient getClient() {
        return client;
    }

   /**
    * Handles the right-clicking of the GameScenePanel.
    * Major error checking is done here and not in children.
    * 
    * @author Tim Pruitt
    *
    * @param  item The item that was right-clicked. item is null if the user
    *  right-clicked on the Item2D world.
    *
    * @see displayPopup(int command, int itemIndex)
    * @see displayPopup(int command)
    * @see displayPopup(String display)
    * @see displayPopupItemDetails(Item2D item)
    * @see displayPopupVehicleConditions(Automobile tempVehicle)
    */
    public void handleSceneClick(Item2D item)
    {
        rightClickX = mainFrame.gameScenePanel.mouseCursor.getXPosition();
        rightClickY = mainFrame.gameScenePanel.mouseCursor.getYPosition();

        rightClickedItem = item;

        popupRightClick = new ScenePopupMenu( this.getClient() );

        localPlayer = client.getLocalPlayer();
        if (localPlayer == null) {
            System.out.println("handleSceneClick(Item2D item): localPlayer is null");
            return;
        }

        session = client.getSession();
        if (session == null) {
            System.out.println("handleSceneClick(Item2D item): session is null");
            return;
        }

        // local player is a spectator
        if (localPlayer.getRoles().isEmpty()) {
            this.displayDirections( Feedback.RIGHT_CLICK_SPECTATOR );
            return;
        }

        boolean isVehicle = false;
        Automobile tempVehicle = null;
        if (item instanceof Automobile) {
            isVehicle = true;
            tempVehicle = (Automobile) item;

            //this.displayDirections( Feedback.RIGHT_CLICK_VEHICLE );

            displayPopupVehicleConditions(tempVehicle);            
        }
        else {
            //this.displayDirections( Feedback.RIGHT_CLICK_ITEM );

            displayPopupItemDetails(item);            
        }

        switch ( session.getMode() ) {
            case Session.MODE_PLAY:
                if ( !isVehicle && canMoveVehicleHere(item) ) {
                    displayPopup(RightClickCommands.MOVE_VEHICLE_HERE);
                }
                // Do not need since victim is considered a responder now
                //if ( isVehicle && canMoveVictim(tempVehicle) ) {
                //    displayPopup(RightClickCommands.REQUEST_VICTIM_MOVE);
                //}
                if (isVehicle && tempVehicle.getRoleId() == Role.IDOT) {
                    displayRightClickLights(tempVehicle.getLightStatus());
                }
                if ( isVehicle && canRequestResponderMove(tempVehicle) ) {
                    displayPopup(RightClickCommands.REQUEST_RESPONDER_MOVE);
                }
                if ( isVehicle && canTow(tempVehicle) ) {
                    displayPopup(RightClickCommands.TOW_VEHICLE);
                }
                if ( isVehicle && canPutOutFire(tempVehicle) ) {
                    displayPopup(RightClickCommands.PUT_OUT_FIRE);
                }
                if ( isVehicle && canLeave(tempVehicle)) {
                    displayPopup(RightClickCommands.LEAVE_SCENE);
                }
                if ( isVehicle &&
                        localPlayer.containsRole( tempVehicle.getRoleId() ) &&
                        tempVehicle != localPlayer.getCurrentCar() ) {
                    displayPopup(RightClickCommands.SWITCH_TO_VEHICLE);
                }

                popupRightClick.addSeparator();

                if ( isVehicle && canCheckVictims(tempVehicle) ) {
                    displayPopup(RightClickCommands.CHECK_VICTIM);
                }
                insertItems();
                pickUpItems();

                //popupRightClick.addSeparator();

                //playRole();
                //stopRole();

                break;
            case Session.MODE_EDITOR:
                if (item.getType().equals(ServerConstants.ITEM_TYPE_NAME[ServerConstants.WORLD])) {
                    placeAllVehicles();
                    insertRoadways();
                }
                else if ( isLane(item) ) {
                    placeAllVehicles();
                    displayPopup(RightClickCommands.REMOVE);
                }
                else if (isVehicle) {
                    Automobile currentCar = localPlayer.getCurrentCar();

                    if (currentCar == item) {
                        setConditions( tempVehicle );
                        displayPopup(RightClickCommands.REMOVE);
                    }
                    else if ( localPlayer.containsRole(tempVehicle.getRoleId()) &&
                            currentCar != item)  {
                        displayPopup(RightClickCommands.SWITCH_TO_VEHICLE);
                    }
                }

                break;
            case Session.MODE_REVIEW:
                this.displayDirections( Feedback.RIGHT_CLICK_REVIEW_MODE );
                return;
        }

        add(popupRightClick);
        popupRightClick.show(mainFrame.gameScenePanel, getRightClickX(), getRightClickY());
    }

    /**
     * displays the condition options of a right-clicked vehicle in the
     *  popupRightClick window.
     *
     * @author Tim Pruitt
     *
     * @param vehicle The vehicle in which the conditions can be manipulated.
     */
    void setConditions(Automobile vehicle) {
        if (vehicle.isMoveable()) {
            displayPopup(RightClickCommands.SET_TO_NONMOVEABLE);
        }
        else {
            displayPopup(RightClickCommands.SET_TO_MOVEABLE);
        }

        if (vehicle.isDamaged()) {
            displayPopup(RightClickCommands.SET_TO_NONDAMAGED);
        }
        else {
            displayPopup(RightClickCommands.SET_TO_DAMAGED);
        }

        if (vehicle.isOnFire()) {
            displayPopup(RightClickCommands.SET_TO_NO_FIRE);
        }
        else {
            displayPopup(RightClickCommands.SET_TO_ON_FIRE);
        }

        popupRightClick.addSeparator();
    }

    /**
     * Displays an inserting option for every vehicle in the popupRightClick
     *  window. Adds a seperator afterwards.
     *
     * @author Tim Pruitt
     */
    void placeAllVehicles() {
        for (int index = 0; index <  Role.ROLE_VEHICLE_NAMES.length; index++) {
            displayPopup(RightClickCommands.INSERT_ITEM, index);
        }
        popupRightClick.addSeparator();
    }

    /**
     * Displays an inserting option for every type of lane in the
     *  popupRightClick window. Adds a separator in between each lane type and
     *  afterwards.
     *
     * @author Tim Pruitt
     */
    void insertRoadways() {
        displayPopup(RightClickCommands.INSERT_ITEM, ServerConstants.HORIZONTAL_LANE);
        displayPopup(RightClickCommands.INSERT_ITEM, ServerConstants.VERTICAL_LANE);

        popupRightClick.addSeparator();

        displayPopup(RightClickCommands.INSERT_ITEM, ServerConstants.HORIZONTAL_SHOULDER);
        displayPopup(RightClickCommands.INSERT_ITEM, ServerConstants.VERTICAL_SHOULDER);

        popupRightClick.addSeparator();

        displayPopup(RightClickCommands.INSERT_ITEM, ServerConstants.LEFT_OFF_RAMP);
        displayPopup(RightClickCommands.INSERT_ITEM, ServerConstants.RIGHT_OFF_RAMP);

        popupRightClick.addSeparator();

        displayPopup(RightClickCommands.INSERT_ITEM, ServerConstants.LEFT_ON_RAMP);
        displayPopup(RightClickCommands.INSERT_ITEM, ServerConstants.RIGHT_ON_RAMP);

        popupRightClick.addSeparator();
    }

    /**
     * Displays/Stores a command and itemIndex for the adjoining option in the
     *  popupRightClick window.
     *
     * @author Tim Pruitt
     *
     * @param command The manipulation factor.
     * @param itemIndex The item index on which you are trying to manipulate
     */
    private void displayPopup(int command, int itemIndex)
    {
        /**
         * The MenuItem being added into the popupRightClick window.
         *
         * @author Tim Pruitt
         */
        MenuItem mi;


        mi = new MenuItem(RightClickCommands.rightClick[command] + ServerConstants.ITEM_DISPLAY_NAME[itemIndex]);
        mi.addActionListener(popupRightClick);
        popupRightClick.add(mi, command, itemIndex);
    }

    /**
     * Displays/Stores a command for the adjoining option in the popupRightClick
     *  window.
     *
     * @author Tim Pruitt
     * 
     * @param command The action being done.
     */
    private void displayPopup(int command)
    {
        /**
         * The MenuItem being added into the popupRightClick window.
         *
         * @author Tim Pruitt
         */
        MenuItem mi;

        mi = new MenuItem(RightClickCommands.rightClick[command]);
        mi.addActionListener(popupRightClick);
        popupRightClick.add(mi, command);
    }

    /**
     * Displays a field in the popupRightClick window. Since it is just for
     *  display, it is disabled.
     *
     * @author Tim Pruitt
     *
     * @param display The string being displayed.
     */
    private void displayPopup(String display)
    {
        /**
         * The MenuItem being added into the popupRightClick window.
         *
         * @author Tim Pruitt
         */
        MenuItem mi;

        mi = new MenuItem(display);
        mi.setEnabled(false);
        mi.addActionListener(popupRightClick);
        popupRightClick.add(mi);
    }

    /**
     * Checks to see if localPlayer's current vehicle is able to check victims in
     *  another vehicle
     *
     * @author Tim Pruitt
     *
     * @param vehicle The vehicle being checked upon.
     *
     * @return true if the localPlayer is able to check on victims in vehicle; false if otherwise
     */
    public boolean canCheckVictims(Automobile vehicle) {
        localPlayer = client.getLocalPlayer();

        if (localPlayer != null && vehicle != null) {
            if ( vehicle.isDamaged() ) {
                LinkedList<Item> items = localPlayer.getCurrentCar().getItemList();
                for (int index = 0; index < items.size(); index++) {
                    if (items.get(index).getType().equals("firstaid")) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    /**
     * Displays the option of stop playing a role in the popupRightClick window.
     *
     * @author Tim pruitt
     *
     * @see playRole()
     */
    public void stopRole() {
        if (rightClickedItem != null && rightClickedItem instanceof Automobile) {
            Automobile vehicle = (Automobile) rightClickedItem;
            if (vehicle == null) {
                System.err.println("stopRole(): vehicle is null. Returning...");
                return;
            }

            int roleId = vehicle.getRoleId();

            localPlayer = client.getLocalPlayer();
            if (localPlayer.containsRole(roleId)) {
                //displayPopup(RightClickCommands.STOP_ROLE, Role.getRoleName(roleId));
            }
        }
    }

    /**
     * Displays the option of playing a role in the popupRightClick window.
     *
     * @author Tim pruitt
     *
     * @see stopRole()
     */
    public void playRole() {
        if (rightClickedItem != null && rightClickedItem instanceof Automobile) {
            Automobile vehicle = (Automobile) rightClickedItem;
            session = client.getSession();
            Vector<Player> playerList = session.getPlayerList();
            int roleId = vehicle.getRoleId();

            for (int index = 0; index < playerList.size(); index++) {
                if (playerList.get(index).containsRole(roleId)) {
                    return;
                }
            }

            //displayPopup(RightClickCommands.PLAY_ROLE, Role.getRoleName(roleId));
            //displayPopup(RightClickCommands.PLAY_ROLE + Role.getRoleVehicleName(roleId));
        }
    }

    /**
     * displays in the popupRightClick window the option of picking up an item.
     *
     * @author Tim Pruitt
     */
    public void pickUpItems() {
        localPlayer = client.getLocalPlayer();
        if (localPlayer == null) {
            System.out.println("pickUpItems(): localPlayer is null. Returning...");
            return;
        }

        if ( rightClickedItem != null &&
                !(rightClickedItem instanceof Automobile) &&
                !(isLane(rightClickedItem)) &&
                !(rightClickedItem.getType().equals(ServerConstants.ITEM_TYPE_NAME[ServerConstants.WORLD]))
                && localPlayer.getCurrentCar() != null) {

            displayPopup(RightClickCommands.PICK_UP_ITEM);
        }
        
        System.out.println(rightClickedItem.getType());
    }

    /**
     * Checks to see if a  particular item is a lane.
     *
     * @author Tim Pruitt
     *
     * @param item The item being compared to a lane.
     *
     * @return True if item is a lane; false otherwise
     */
    private boolean isLane(Item2D item) {
        if (item.getClass().toString().equals( Lane.class.toString()) ) {
            return true;
        }
        else {
            return false;
        }
    }

    /**
     * Displays in the popupRightClick window the options of inserting various
     *  items. The currentCar must hold those items to be able to have the option.
     *
     * @author Tim Pruitt
     */
    public void insertItems() {
        localPlayer = client.getLocalPlayer();

        if (localPlayer == null) {
            System.out.println("insertItems(): localPlayer is null. Returning...");
            return;
        }

        if (localPlayer.getCurrentCar() == null) {
            System.out.println("insertItems(): currentCar is null. Returning...");
            return;
        }

        if (rightClickedItem == null) {
            System.out.println("insertItems(): rightClickedItem is null. Returning...");
            return;
        }

        if (isLane(rightClickedItem) || rightClickedItem == client.getSession().getCurrentScenario().getWorld()) {
            LinkedList<String> insertedItems = new LinkedList();
            Item item;
            LinkedList<Item> playerItems = localPlayer.getCurrentCar().getItemList();

            for (int index = 0; index < playerItems.size(); index++) {
                item = playerItems.get(index);
                if ( item instanceof Item2D) {
                       if (!insertedItems.contains(item.getType())) {

                           boolean found = false;
                           for (int serverIndex = 0; serverIndex < ServerConstants.ITEM_TYPE_NAME.length && !found; serverIndex++)
                           {
                               if (item.getType().equals( ServerConstants.ITEM_TYPE_NAME[serverIndex] ))
                               {
                                   displayPopup(RightClickCommands.INSERT_ITEM, serverIndex);
                                   insertedItems.add(item.getType());
                                   found = true;
                               }
                           }
                       }
                }
            }
        }
    }

    /**
     * Checks to see if a particular vehicle is able to leave the scene.
     * Must be able to move and must be localPlayer's currentCar.
     *
     * @author Tim Pruitt
     *
     * @param vehicle The vehicle being examined on whether or not it can leave
     *  the scene.
     *
     * @return True if vehicle is able to leave; false otherwise
     */
    public boolean canLeave(Automobile vehicle) {
        localPlayer = client.getLocalPlayer();

        Automobile currentVehicle = this.getLocalPlayer().getCurrentCar();

        if (currentVehicle != null && currentVehicle.isMoveable() && currentVehicle == vehicle) {
            return true;
        }
        else {
            return false;
        }
    }

    /**
     * Checks to see if localPlayer's currentCar is able to tow away vehicle.
     * currentCar must be a tow truck and vehicle must be disabled.
     *
     * @author Tim Pruitt
     *
     * @param vehicle The Automobile being checked to see if it is able to be
     *  towed.
     *
     * @return True if able to tow; False otherwise
     */
    public boolean canTow(Automobile vehicle) {
        localPlayer = client.getLocalPlayer();

        if (localPlayer == null || vehicle == null) {
            return false;
        }
        else {
            Automobile currentVehicle = localPlayer.getCurrentCar();

            if (currentVehicle == null) {
                return false;
            }
            else {
                Role currentRole = localPlayer.getCurrentRole();
                if (currentRole == null) {
                    return false;
                }
                else if ( localPlayer.getCurrentRole().getId() == Role.TOW &&
                        !vehicle.isMoveable() && currentVehicle != vehicle
                        && currentVehicle.isMoveable() ) {
                    return true;
                }
                else {
                    return false;
                }
            }
        }
    }

    /**
     * Checks to see if localPlayer is able to request a particular vehicle
     *  to move.
     *
     * @author Tim Pruitt
     *
     * @param vehicle The vehicle being checked to see if localPlayer can request
     *  it to move
     *
     * @return True if localPlayer is able to request vehicle to move;
     * False otherwise
     */
    public boolean canRequestResponderMove(Automobile vehicle) {
        localPlayer = client.getLocalPlayer();

        if (localPlayer == null || vehicle == null) {
            return false;
        }
        else {
            Automobile currentVehicle = localPlayer.getCurrentCar();
            Role currentRole = localPlayer.getCurrentRole();

            if (currentVehicle == null || currentRole == null) {
                return false;
            }
            else {
                if (!localPlayer.containsRole(vehicle.getRoleId()) && vehicle.isMoveable()) {
                    return true;
                }
                else {
                    return false;
                }
            }
        }
    }

    /**
     * Checks to see if localPlayer's current car is able to move where item
     *  is located.
     *
     * @author Tim Pruitt
     *
     * @param item The Item2D that is being checked to see if localPlayer's
     *  currentCar is able to move there.
     *
     * @return True if localPlayer's currentCar can move there; False otherwise
     */
    public boolean canMoveVehicleHere(Item2D item) {
        session = client.getSession();
        if (session == null) {
            System.out.println("canMoveVehicleHere(Item2D item): session is null");
            return false;
        }

        localPlayer = client.getLocalPlayer();
        if (localPlayer == null) {
            System.out.println("canMoveVehicleHere(Item2D item): localPlayer is null");
            return false;
        }

        Automobile currentCar = localPlayer.getCurrentCar();
        if (currentCar == null) {
            System.out.println("canMoveVehicleHere(Item2D item): currentCar is null");
            return false;
        }

        if (item == null) {
            System.out.println("canMoveVehicleHere(Item2D item): item is null");
            return false;
        }

        if ( currentCar.isMoveable() && (isLane(item) || item == session.getCurrentScenario().getWorld()) ) {
            return true;
        }
        else {
            return false;
        }
    }

    /**
     * Checks to see if the localPlayer can request a victim vehicle can move.
     *
     * @author Tim Pruitt
     *
     * @param vehicle The vehicle being examined
     *
     * @return True if vehicle is a victim car and localPlayer can request
     *  its move; False otherwise
     */
    public boolean canMoveVictim(Automobile vehicle) {
        localPlayer = client.getLocalPlayer();
        if (localPlayer == null) {
            return false;
        }
        else {
            Automobile currentVehicle = localPlayer.getCurrentCar();

            if (currentVehicle == null) {
                return false;
            }
            else {
                Role currentRole = localPlayer.getCurrentRole();
                if (currentRole == null) {
                    return false;
                }
                else if (vehicle.getRoleId() == Role.VICTIM &&
                        vehicle.isMoveable() && currentRole.getId() != Role.VICTIM) {
                    return true;
                }
                else {
                    return false;
                }
            }

        }
    }

    /**
     * Checks to see if an Item2D is a victim.
     *
     * @author Tim Pruitt
     *
     * @param item The Item2D being examined.
     *
     * @return True if item is a victim car; False otherwise
     */
    public boolean isVictim(Item2D item) {
        if (item instanceof Automobile) {
            Automobile vehicle = (Automobile) item;
            if (vehicle.getRoleId() == Role.VICTIM) {
                return true;
            }
        }
        return false;
    }

    /**
     * Gets the x-coordinate of the right-click.
     *
     * @author Tim Pruitt
     *
     * @return the x-coordinate of the right-click.
     *
     * @see getRightClickY()
     */
    public int getRightClickX() {
        return rightClickX;
    }

    /**
     * Gets the x-coordinate of the right-click.
     *
     * @author Tim Pruitt
     *
     * @return the y-coordinate of the right-click.
     *
     * @see getRightClickX()
     */
    public int getRightClickY() {
        return rightClickY;
    }

    /**
     * Gets the Item2D that was right-clicked on.
     *
     * @author Tim Pruitt
     *
     * @return The Item2D that was right-clicked on.
     */
    public Item2D getRightClickedItem() {
        return rightClickedItem;
    }
    
    /**
     * refreshMainScreen updates all relevant GUI items within the main screen to match current session conditions.
     * @author adieffe
     */
    public void refreshMainScreen()
    {
        refreshItems();
        refreshScenario();
        refreshResponders();
        refreshVehicle();
        refreshMessages();
        refreshTime();
    }

    /**
     * Updates Item GUI components to match current player's current active
     *  role/car iventory.
     *
     * @author Tim Pruitt
     */
    public void refreshItems()
    {
        localPlayer = client.getLocalPlayer();
        if (localPlayer == null) {
            System.out.println("refreshItems(): localPlayer is null. Returning...");
            return;
        }

        session = client.getSession();
        if (session == null) {
            System.out.println("refreshItems(): session is null. Returning...");
            return;
        }

        // Update the icons
        //for (int x = 0; x < itemLabels.length; x++) {
        //    itemLabels[x].setIcon( ServerConstants.ITEM_PHOTO_LOCATION[VEHICLE_ITEMS[x]] );
        //}


        // Update the Item Names
        for (int i = 0; i < itemNames.length; i++) {
            itemNames[i].setText(ServerConstants.ITEM_DISPLAY_NAME[ VEHICLE_ITEMS[i] ]);
        }

        Automobile currentCar = localPlayer.getCurrentCar();
        if (currentCar == null) {
            System.out.println( "resfreshItems():  no currentCars! " );

            //Set all counts to 0
            for (int i = 0; i <itemCounts.length; i++)
            {
                itemCounts[i].setText("0");
            }

            //Disable all items
            for (int x = 0; x < VEHICLE_ITEMS.length; x++) {
                setItemEnabling(x, false);
            }
        }
        else {
            // Set all the item counts
            String itemType[] = ServerConstants.ITEM_TYPE_NAME;
            Integer itemCount;
            for (int x = 0; x < itemCounts.length; x++) {
                itemCount = currentCar.getItemCountByType( itemType[VEHICLE_ITEMS[x]] );

                if (itemCount < 0 ) {
                    System.err.println("refreshItems(): itemCount for item " + x + "is not >= 0");
                    itemCounts[x].setText( "0" );
                }
                else {
                    itemCounts[x].setText( itemCount.toString() );
                }
            }

            int mode = client.getSession().getMode();
            switch (mode) {
                case Session.MODE_PLAY: // Enable items with count > 0
                                        // Disable the rest
                    for (int x = 0; x < VEHICLE_ITEMS.length; x++) {
                        itemCounts[x].setEditable(false);
                        itemCounts[x].setOpaque(false);

                        if (Integer.parseInt(itemCounts[x].getText()) > 0) {
                            setItemEnabling(x, true);
                        }
                        else {
                            setItemEnabling(x, false);
                        }
                    }
                        break;

                case Session.MODE_EDITOR: // Enable all Items
                    for (int x = 0; x < VEHICLE_ITEMS.length; x++) {
                        itemCounts[x].setEditable(true);
                        itemCounts[x].setOpaque(true);
                        itemCounts[x].setBackground(EDITABLE_COLOR);

                        setItemEnabling(x, true);
                    }
                    break;

                case Session.MODE_REVIEW: // Disable all Items
                    for (int x = 0; x < VEHICLE_ITEMS.length; x++) {
                        itemCounts[x].setEditable(false);
                        itemCounts[x].setOpaque(false);

                        setItemEnabling(x, false);
                    }
                    break;
                    
                default:
                    System.out.println("refreshItems(): Unable to read mode");
            }
        }

        System.out.println("refreshItems(): Items have been refreshed");
    }

    /**
     * Sets a specific item to disabled or enabled.
     *
     * @author Tim Pruitt
     *
     * @param itemIndex The item being manipulated.
     * @param enabling The updated boolean value of the component's enabling.
     */
    public void setItemEnabling(int itemIndex, boolean enabling) {
        itemLabels[itemIndex].setEnabled(enabling);
        itemNames[itemIndex].setEnabled(enabling);
        itemCounts[itemIndex].setEnabled(enabling);
    }

    /**
     * refreshScenario updates Scenario (label) GUI to match the currently
     *  played Scenario.
     *
     * @author Tim Pruitt
     */
    public void refreshScenario()
    {
        localPlayer = client.getLocalPlayer();
        session = client.getSession();

        if (session == null) {
            System.out.println("refreshScenario(): session is null");
            return;
        }
        if (localPlayer == null) {
            System.out.println("refreshScenario(): localPlayer is null");
            return;
        }

        /**
         * The current scenario of the session.
         *
         * @author Tim Pruitt
         */
        Scenario currentScenario = session.getCurrentScenario();
        if( currentScenario == null ) {
            System.out.println( "refreshScenario(): currentScenario is null!" );
            return;
        }

        // Set the values for the scenario description and name
        switch (session.getMode()) {
            case Session.MODE_EDITOR:
                if (currentScenario.getDescription().isEmpty()) {
                    lblDescription.setText(GUIPrompts.SCENARIO_INSERT_TEXT);
                }
                else {
                    lblDescription.setText(currentScenario.getDescription());
                }

                if (currentScenario.getName().isEmpty()) {
                    this.txtScenarioName.setText(GUIPrompts.SCENARIO_NAME_INSERT_TEXT);
                }
                else {
                    txtScenarioName.setText(currentScenario.getName());
                }
                break;
            case Session.MODE_PLAY:
            case Session.MODE_REVIEW:
                lblDescription.setText(currentScenario.getDescription());
                txtScenarioName.setText(currentScenario.getName());
                break;
            default:
                System.out.println("refreshScenario(): Could not find mode.");
        }

        // Enable or Disable the create scenario button
        if (localPlayer.getType().equals(Player.TYPE_INSTRUCTOR)) {
            btnCreateScenario.setEnabled(true);
        }
        else {
            btnCreateScenario.setEnabled(false);
        }

        // Display time.
        refreshTime();

        //Update the scenario list
        listScenarios.removeAll();
        listScenarios.clearSelection();

        /**
         * A DefaultListModel that gets populated with the scenarios and inserts
         *  that list into the listScenarios component.
         *
         * @author Tim Pruitt
         */
        DefaultListModel list = new DefaultListModel();

        /**
         * The list of scenarios in the current session.
         *
         * @author Tim Pruitt
         */
        Vector<Scenario> scenarioList = session.getScenarioList();
        for (int index = 0; index < scenarioList.size(); index++) {
            list.addElement( scenarioList.elementAt(index).getName() );
        }
        listScenarios.setModel(list);
        
        setBtnScenarioEnable();

        System.out.println("The scenario has been refreshed.");
    }

    /**
     * Updates Responders (label) GUI to match the names/currently played
     *  responder roles.
     *
     * @author Tim Pruitt
     */
    public void refreshResponders()
    {
        localPlayer = client.getLocalPlayer();

        if( client.getSession() == null || localPlayer == null )
        {
            return;
        }

        int mode = client.getSession().getMode();

        switch (mode)
        {
            case Session.MODE_EDITOR:
            case Session.MODE_REVIEW:
                for (int x = 0; x < RESPONDER_COUNT; x++) {
                    setRoleEnabling(x, false);
                    responderButton[x].setVisible(false);
                }
                setResponderNames();
                break;

            case Session.MODE_PLAY:
                // Set the Visibility and Labels
                for (int x = 0; x < RESPONDER_COUNT; x++) {
                    setRoleEnabling(x, true);
                    responderLabel[x].setText(Role.ROLE_NAMES[x] + ":");
                    responderLabel[x].setEnabled(true);
                }

                setResponderNames();

                // Set the button conditions
                for (int i = 0; i < responderName.length; i++) {
                    if (responderName[i].getText().equals("")) {
                        responderButton[i].setText(ADD_ROLE);
                        responderButton[i].setVisible(true);
                    }
                    else if (responderName[i].getText().equals(localPlayer.getName())){
                        responderButton[i].setText(DROP_ROLE);
                        responderButton[i].setVisible(true);
                    }
                    else {
                        responderButton[i].setVisible(false);
                    }
                }

                if ( localPlayer.getRoles().isEmpty() ) {
                    comboRequest.setEnabled(false);
                }
                else {
                    comboRequest.setEnabled(true);
                }
                break;

            default:
                System.out.println("refreshResponders(): Could not read mode");
        }
    }

    /**
     * Sets a specific role either to enabled or disabled.
     *
     * @author Tim Pruitt
     *
     * @param index The role index of the designated role.
     * @param enabling The boolean value of its updated enabling.
     */
    private void setRoleEnabling(int index, boolean enabling) {
        responderLabel[index].setEnabled(enabling);
        responderName[index].setEnabled(enabling);
        responderButton[index].setEnabled(enabling);
    }

    /**
     * Sets the responder names in the Responder Window.
     *
     * @author Tim Pruitt
     */
    private void setResponderNames()
    {
        session = client.getSession();
        Vector<Player> players = session.getPlayerList();
        Vector<Role> roles;
        Role role;

        // Clear all responder names (in the case a role is not being played?).
        for (int x = 0; x < RESPONDER_COUNT; x++)
        {
            responderName[x].setText("");
        }

        // Iterate through players and their roles and set responder view role names accordingly.
        for (int i = 0; i < players.size(); i++)
        {
            Player player = players.get(i);
            roles = player.getRoles();

            for (int j = 0; j < roles.size(); j++)
            {
                role = roles.elementAt(j);
                responderName[role.getId()].setText(player.getName());
            }
        }
    }

   /**
    * Updates the time according to what the current time is in the
    *  current scenario.
    *
    * @author Tim Pruitt
    * @author Andrew
    *
    * @see refreshMainScreen
    * @see refreshItems
    * @see refreshScenario
    * @see refreshResponders
    * @see refreshVehicle
    * @see refreshMessages
    */
    public void refreshTime()
    {
        localPlayer = client.getLocalPlayer();
        session = client.getSession();

        if( session == null || localPlayer == null )
        {
            clockEnabling(false);
            return;
        }
        clockEnabling(true);

        // TODO client
        Scenario currentScenario = session.getCurrentScenario();

        double hours, minutes, seconds;
        double total_hours, total_minutes, total_seconds;

        // NOTE: I think this algorithm works right.
        total_seconds   = currentScenario.getCurrentTime();

        seconds         = total_seconds % 60;
        total_minutes   = total_seconds / 60;
        minutes         = total_minutes % 60;
        total_hours     = total_minutes / 60;
        hours           = total_hours % 24;

        String hoursString       = ((Integer)((int)hours)).toString();
        String minutesString    = ((Integer)((int)minutes)).toString();
        String secondsString    = ((Integer)((int)seconds)).toString();

        if( hoursString.length() < 2 )
        {
            hoursString = "0" + hoursString;
        }

        if( minutesString.length() < 2 )
        {
            minutesString = "0" + minutesString;
        }

        if( secondsString.length() < 2 )
        {
            secondsString = "0" + secondsString;
        }

        // Display time.
        lblClock.setText( hoursString + " : " + minutesString + " : " + secondsString );
        
        //System.out.println("The current time has been updated to " + lblClock.getText());
    }

    /**
     * Sets the clock to either enabled or disabled.
     *
     * @author Tim Pruitt
     *
     * @param value The boolean value of the clock's updated enabling
     */
    public void clockEnabling(boolean value) {
        //imgClock.setEnabled(value);
        lblClock.setEnabled(value);
    }

    /**
     * refreshVehicle updates Vehicle (label) GUI to match the names/currently played responder roles.
     * @author adieffe
     * @author Tim Pruitt
     */
    public void refreshVehicle()
    {
        refreshPlayerCars();
        localPlayer = client.getLocalPlayer();
        
        if( client.getSession() == null || localPlayer == null )
        {
            System.out.println("refresh vehicle fuck up");
            return;
        }

        String vehicleBorderText = "Vehicle";
        TitledBorder tempBorder = ( TitledBorder )frmVehicle.getBorder();

        // Make sure there is actually a current car.
        Automobile currentCar = localPlayer.getCurrentCar();
        if( localPlayer != null )
        {            
            if( currentCar == null )
            {
                // Empty the vehicle info, as there is no current car.
                tempBorder.setTitle( vehicleBorderText );
                imgVehicle.setIcon( null );
                vehicleEnabling(false);
                frmVehicle.updateUI();
                return;
            }
            else
            {
                Image vehicleImage = mainFrame.gameScenePanel.carSpriteList.get( currentCar.getRoleId() ).getBuffer();

                if( vehicleImage != null )
                {
                    // Change title text of vehicle view.
                    String roleVehicleName  = Role.getRoleVehicleName( currentCar.getRoleId() );
                    String currentCarId     = ( ( Integer )currentCar.getInstance() ).toString();
                    vehicleBorderText       = vehicleBorderText + " - " + roleVehicleName + " ( " + currentCarId + " )";
                    tempBorder.setTitle( vehicleBorderText );
                    frmVehicle.updateUI();

                    // Draw tire image for this vehicle.
                    ImageIcon tireImageIcon = new ImageIcon( getClass().getResource( "/graphics/tire_50x50.png" ) );
                    Image tireImage = tireImageIcon.getImage();
                    BufferedImage tempTireImage = new BufferedImage( tireImage.getWidth(this), tireImage.getHeight(this), BufferedImage.TYPE_INT_ARGB );
                    Graphics2D graphics = ( Graphics2D )tempTireImage.getGraphics();
                    graphics.rotate( Math.toRadians( currentCar.getWheelAngle() ), tempTireImage.getWidth()/2, tempTireImage.getHeight()/2);
                    graphics.drawImage( tireImage, 0, 0, this );
                    tireImageIcon = new ImageIcon( tempTireImage );
                    imgWheelAngle.setIcon( tireImageIcon );

                    // Change image of vehicle.
                    Image smallerImage = vehicleImage.getScaledInstance( imgVehicle.getWidth() - 40, imgVehicle.getHeight() - 20, Image.SCALE_SMOOTH );
                    ImageIcon tempIcon = new ImageIcon( smallerImage );
                    imgVehicle.setIcon( tempIcon );

                    vehicleEnabling(true);
                }

                // set the properties of the controls
                sliderRotate.setValue( (int)currentCar.getAngle() );
            }
        }
    }

    /**
     * Refreshed the local player's cars; includes car types, items and conditions.
     *
     * @author Tim Pruitt
     */
    private void refreshPlayerCars()
    {
        localPlayer = client.getLocalPlayer();
        session = client.getSession();

        if( localPlayer == null )
        {
            return;
        }

        /**
         * The list of items the local player contains.
         *
         * @author Tim Pruitt
         */
        LinkedList<Item> itemList = localPlayer.getItemList();

        if( itemList != null )
        {
            itemList.clear();
        }
        else
        {
            return;
        }

        /**
         * The current scenario of the local session.
         *
         * @author Tim Pruitt
         */
        Scenario currentScenario = session.getCurrentScenario();

        /**
         * The world item of the current scenario.
         *
         * @author Tim Pruitt
         */
        Item2D world = currentScenario.getWorld();

        /**
         * The item being refreshed.
         *
         * @author Tim Pruitt
         */
        Item item;

        /**
         * The car being refreshed.
         *
         * @author Tim Pruitt
         */
        Automobile car;

        /**
         * The list of items the world contains.
         *
         * @author Tim Pruitt
         */
        LinkedList<Item> worldItemList = world.getItemList();

        if( worldItemList == null )
        {
            return;
        }

        for (int i = 0; i < worldItemList.size(); i++)
        {
            item = worldItemList.get(i);
            if (item instanceof Automobile)
            {
                car = (Automobile)item;
                if (localPlayer.containsRole(car.getRoleId()))
                {
                        localPlayer.itemList.add(car);
                }
            }
        }
    }

    /**
     * Sets the vehicle window's enabling/disabling.
     *
     * @author Tim Pruitt
     *
     * @param value The boolean value of the updated enabling.
     */
    private void vehicleEnabling(boolean value) {
        localPlayer = client.getLocalPlayer();
        if (localPlayer == null) {
            System.err.println("vehicleEnabling(value): local Player is null. Returning...");
            return;
        }

        /**
         * localPlayer's current vehicle.
         *
         * @author Tim Pruitt
         */
        Automobile currentCar = localPlayer.getCurrentCar();

        if ( currentCar != null && !currentCar.isMoveable() && client.getSession().getMode() != Session.MODE_EDITOR) {
            sliderRotate.setEnabled(false);
            setWheelAngleEnabling(false);
        }
        else {
            sliderRotate.setEnabled(value);
            setWheelAngleEnabling(value);
        }


        frmVehicle.setEnabled(value);
        btnPreviousVehicle.setEnabled(value);
        btnNextVehicle.setEnabled(value);
        imgVehicle.setEnabled(value);
    }

    /**
     * Sets the wheel angle window enabling.
     *
     * @author Tim Pruitt
     *
     * @param value The updated boolean value in which the wheel angle will be
     *  enabled/disabled.
     */
    private void setWheelAngleEnabling(boolean value) {
        frmWheelAngle.setEnabled(value);
        btnWheelAngleLeft.setEnabled(value);
        btnWheelAngleRight.setEnabled(value);
        imgWheelAngle.setEnabled(value);
    }

    /**
     * refreshVehicle updates Messages (label) GUI to match the session's message/chat log.
     * @author adieffe
     */
    public void refreshMessages()
    {
        localPlayer = client.getLocalPlayer();
        session = client.getSession();

        if( session == null || localPlayer == null )
        {
            return;
        }
    }

    /**
     * Enables/Disables the ability to type and send messages as well as create
     *  scenarios and request additional vehicles.
     *
     * @author Tim Pruitt
     *
     * @param value The boolean value in which to enable/disable the components.
     */
    public void setMessageEnabling(boolean value) {
        localPlayer = client.getLocalPlayer();
        if (localPlayer.getCurrentRole() == null) {
            value = false;
        }

        txtboxChat.setEnabled(value);
        txtTypeMessage.setEnabled(value);
        btnSendMessage.setEnabled(value);
        comboRequest.setEnabled(value);
        btnCreateScenario.setEnabled(value);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dialogRequest = new javax.swing.JDialog();
        frmRequestTo = new javax.swing.JPanel();
        radioBtnPolice = new javax.swing.JRadioButton();
        radioBtnFire = new javax.swing.JRadioButton();
        radioBtnEms = new javax.swing.JRadioButton();
        radioBtnIdot = new javax.swing.JRadioButton();
        frmRequests = new javax.swing.JPanel();
        btnRequestMoveCar = new javax.swing.JButton();
        btnRequestMoveCone = new javax.swing.JButton();
        btnRequestMoveSign = new javax.swing.JButton();
        btnRequestAVehicle = new javax.swing.JButton();
        btnCancel = new javax.swing.JButton();
        buttonGroupRequestTo = new javax.swing.ButtonGroup();
        popup = new javax.swing.JPopupMenu();
        frmScenario = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        lblDescription = new javax.swing.JTextArea();
        txtScenarioName = new javax.swing.JTextField();
        lblScenarioName = new javax.swing.JLabel();
        lblClock = new javax.swing.JLabel();
        btnCreateScenario = new javax.swing.JButton();
        btnSave = new javax.swing.JButton();
        btnReplay = new javax.swing.JButton();
        btnFinish = new javax.swing.JButton();
        btnStartScenario = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane5 = new javax.swing.JScrollPane();
        listScenarios = new javax.swing.JList();
        btnSwitchMode = new javax.swing.JButton();
        frmScene = new javax.swing.JPanel();
        frmVehicle = new javax.swing.JPanel();
        btnPreviousVehicle = new javax.swing.JButton();
        imgVehicle = new javax.swing.JLabel();
        btnNextVehicle = new javax.swing.JButton();
        sliderRotate = new javax.swing.JSlider();
        frmWheelAngle = new javax.swing.JPanel();
        imgWheelAngle = new javax.swing.JLabel();
        btnWheelAngleLeft = new javax.swing.JButton();
        btnWheelAngleRight = new javax.swing.JButton();
        frmChat = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtboxChat = new javax.swing.JTextArea();
        txtTypeMessage = new javax.swing.JTextField();
        btnSendMessage = new javax.swing.JButton();
        comboRequest = new javax.swing.JComboBox();
        btnSendRequest = new javax.swing.JButton();
        frmResponders = new javax.swing.JPanel();
        lblPolice = new javax.swing.JLabel();
        lblResponder4 = new javax.swing.JLabel();
        lblResponder3 = new javax.swing.JLabel();
        lblResponder2 = new javax.swing.JLabel();
        lblResponder1 = new javax.swing.JLabel();
        btnEmsResponder = new javax.swing.JButton();
        lblFire = new javax.swing.JLabel();
        lblEMS = new javax.swing.JLabel();
        lblIDOT = new javax.swing.JLabel();
        btnPoliceResponder = new javax.swing.JButton();
        btnIdotResponder = new javax.swing.JButton();
        btnFireResponder = new javax.swing.JButton();
        lblTow = new javax.swing.JLabel();
        lblResponder5 = new javax.swing.JLabel();
        btnTowResponder = new javax.swing.JButton();
        lblVictim = new javax.swing.JLabel();
        lblVictimName = new javax.swing.JLabel();
        btnVictimResponder = new javax.swing.JButton();
        frmHelp = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        lblDirections = new javax.swing.JTextArea();
        jScrollPane3 = new javax.swing.JScrollPane();
        lblHelp = new javax.swing.JTextArea();
        frmItems = new javax.swing.JPanel();
        item0Label = new javax.swing.JLabel();
        lblItem0Count = new javax.swing.JTextField();
        lblItem0Name = new javax.swing.JLabel();
        item1Label = new javax.swing.JLabel();
        lblItem1Count = new javax.swing.JTextField();
        item2Label = new javax.swing.JLabel();
        lblItem2Count = new javax.swing.JTextField();
        item3Label = new javax.swing.JLabel();
        lblItem3Count = new javax.swing.JTextField();
        lblItem1Name = new javax.swing.JLabel();
        lblItem2Name = new javax.swing.JLabel();
        lblItem3Name = new javax.swing.JLabel();

        dialogRequest.setTitle("Make a Request");
        dialogRequest.setResizable(false);
        dialogRequest.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                dialogRequestComponentShown(evt);
            }
        });
        dialogRequest.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                dialogRequestFocusLost(evt);
            }
        });

        frmRequestTo.setBorder(javax.swing.BorderFactory.createTitledBorder("To Whom"));
        frmRequestTo.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                frmRequestToComponentShown(evt);
            }
        });

        radioBtnPolice.setText("Police");
        radioBtnPolice.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        radioBtnPolice.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        radioBtnPolice.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        radioBtnPolice.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                radioBtnPoliceMouseClicked(evt);
            }
        });
        radioBtnPolice.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                radioBtnPoliceFocusGained(evt);
            }
        });

        radioBtnFire.setText("Fire");
        radioBtnFire.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        radioBtnFire.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        radioBtnFire.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                radioBtnFireMouseClicked(evt);
            }
        });
        radioBtnFire.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                radioBtnFireFocusGained(evt);
            }
        });

        radioBtnEms.setText("E.M.S.");
        radioBtnEms.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        radioBtnEms.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        radioBtnEms.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                radioBtnEmsMouseClicked(evt);
            }
        });
        radioBtnEms.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                radioBtnEmsFocusGained(evt);
            }
        });

        radioBtnIdot.setText("I.D.O.T.");
        radioBtnIdot.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        radioBtnIdot.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        radioBtnIdot.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                radioBtnIdotMouseClicked(evt);
            }
        });
        radioBtnIdot.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                radioBtnIdotFocusGained(evt);
            }
        });

        javax.swing.GroupLayout frmRequestToLayout = new javax.swing.GroupLayout(frmRequestTo);
        frmRequestTo.setLayout(frmRequestToLayout);
        frmRequestToLayout.setHorizontalGroup(
            frmRequestToLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frmRequestToLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(radioBtnPolice)
                .addGap(18, 18, 18)
                .addComponent(radioBtnFire)
                .addGap(18, 18, 18)
                .addComponent(radioBtnEms)
                .addGap(18, 18, 18)
                .addComponent(radioBtnIdot))
        );
        frmRequestToLayout.setVerticalGroup(
            frmRequestToLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frmRequestToLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(frmRequestToLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(radioBtnIdot)
                    .addComponent(radioBtnEms)
                    .addComponent(radioBtnFire)
                    .addComponent(radioBtnPolice))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        frmRequests.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        btnRequestMoveCar.setText("Move a Car");
        btnRequestMoveCar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnRequestMoveCarMouseClicked(evt);
            }
        });

        btnRequestMoveCone.setText("Move a Cone");
        btnRequestMoveCone.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnRequestMoveConeMouseClicked(evt);
            }
        });

        btnRequestMoveSign.setText("Move a Sign");
        btnRequestMoveSign.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnRequestMoveSignMouseClicked(evt);
            }
        });

        btnRequestAVehicle.setText("Request Another Vehicle");

        javax.swing.GroupLayout frmRequestsLayout = new javax.swing.GroupLayout(frmRequests);
        frmRequests.setLayout(frmRequestsLayout);
        frmRequestsLayout.setHorizontalGroup(
            frmRequestsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, frmRequestsLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(frmRequestsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnRequestMoveSign, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
                    .addComponent(btnRequestAVehicle, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
                    .addComponent(btnRequestMoveCone, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
                    .addComponent(btnRequestMoveCar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE))
                .addContainerGap())
        );
        frmRequestsLayout.setVerticalGroup(
            frmRequestsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frmRequestsLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btnRequestMoveCar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnRequestMoveCone)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnRequestMoveSign)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnRequestAVehicle)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        btnCancel.setText("Cancel");
        btnCancel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnCancelMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout dialogRequestLayout = new javax.swing.GroupLayout(dialogRequest.getContentPane());
        dialogRequest.getContentPane().setLayout(dialogRequestLayout);
        dialogRequestLayout.setHorizontalGroup(
            dialogRequestLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dialogRequestLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(dialogRequestLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(frmRequests, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(frmRequestTo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 228, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        dialogRequestLayout.setVerticalGroup(
            dialogRequestLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dialogRequestLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(frmRequestTo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(frmRequests, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnCancel)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        setMaximumSize(new java.awt.Dimension(1000, 700));
        setMinimumSize(new java.awt.Dimension(640, 480));
        setPreferredSize(new java.awt.Dimension(1000, 700));

        frmScenario.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Scenario", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12))); // NOI18N
        frmScenario.setFont(frmScenario.getFont().deriveFont((float)7));
        frmScenario.setName("frmScenario"); // NOI18N
        frmScenario.setOpaque(false);
        frmScenario.setPreferredSize(new java.awt.Dimension(200, 200));

        lblDescription.setBackground(new java.awt.Color(236, 233, 216));
        lblDescription.setColumns(16);
        lblDescription.setEditable(false);
        lblDescription.setFont(lblDescription.getFont().deriveFont(lblDescription.getFont().getStyle() & ~java.awt.Font.BOLD, lblDescription.getFont().getSize()-1));
        lblDescription.setLineWrap(true);
        lblDescription.setRows(3);
        lblDescription.setWrapStyleWord(true);
        lblDescription.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        lblDescription.setOpaque(false);
        lblDescription.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                lblDescriptionFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                lblDescriptionFocusLost(evt);
            }
        });
        jScrollPane4.setViewportView(lblDescription);

        txtScenarioName.setFont(new java.awt.Font("Tahoma", 0, 10));
        txtScenarioName.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtScenarioNameFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtScenarioNameFocusLost(evt);
            }
        });

        lblScenarioName.setFont(new java.awt.Font("Tahoma", 0, 10));
        lblScenarioName.setText("Scenario Name:");

        lblClock.setFont(lblClock.getFont().deriveFont(lblClock.getFont().getStyle() | java.awt.Font.BOLD, lblClock.getFont().getSize()-1));
        lblClock.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblClock.setText("lblClock");
        lblClock.setAlignmentX(0.5F);
        lblClock.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        lblClock.setFocusable(false);
        lblClock.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        lblClock.setMaximumSize(new java.awt.Dimension(37, 19));
        lblClock.setMinimumSize(new java.awt.Dimension(37, 19));
        lblClock.setName("lblClock"); // NOI18N
        lblClock.setPreferredSize(new java.awt.Dimension(37, 19));
        lblClock.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                lblClockMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                lblClockMouseExited(evt);
            }
        });

        btnCreateScenario.setFont(btnCreateScenario.getFont().deriveFont(btnCreateScenario.getFont().getStyle() & ~java.awt.Font.BOLD, btnCreateScenario.getFont().getSize()-1));
        btnCreateScenario.setText("Create");
        btnCreateScenario.setMaximumSize(new java.awt.Dimension(37, 19));
        btnCreateScenario.setMinimumSize(new java.awt.Dimension(37, 19));
        btnCreateScenario.setPreferredSize(new java.awt.Dimension(37, 19));
        btnCreateScenario.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnCreateScenarioMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btnCreateScenarioMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                btnCreateScenarioMouseExited(evt);
            }
        });
        btnCreateScenario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCreateScenarioActionPerformed(evt);
            }
        });

        btnSave.setFont(btnSave.getFont().deriveFont(btnSave.getFont().getStyle() & ~java.awt.Font.BOLD, btnSave.getFont().getSize()-1));
        btnSave.setText("Save");
        btnSave.setMaximumSize(new java.awt.Dimension(37, 19));
        btnSave.setMinimumSize(new java.awt.Dimension(37, 19));
        btnSave.setPreferredSize(new java.awt.Dimension(37, 19));
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });

        btnReplay.setFont(btnReplay.getFont().deriveFont(btnReplay.getFont().getStyle() & ~java.awt.Font.BOLD, btnReplay.getFont().getSize()-1));
        btnReplay.setText(" Replay");
        btnReplay.setMaximumSize(new java.awt.Dimension(37, 19));
        btnReplay.setMinimumSize(new java.awt.Dimension(37, 19));
        btnReplay.setPreferredSize(new java.awt.Dimension(37, 19));
        btnReplay.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnReplayActionPerformed(evt);
            }
        });

        btnFinish.setFont(btnFinish.getFont().deriveFont(btnFinish.getFont().getStyle() & ~java.awt.Font.BOLD, btnFinish.getFont().getSize()-1));
        btnFinish.setText("Finish");

        btnStartScenario.setFont(btnStartScenario.getFont().deriveFont(btnStartScenario.getFont().getStyle() & ~java.awt.Font.BOLD, btnStartScenario.getFont().getSize()-1));
        btnStartScenario.setText("Start");
        btnStartScenario.setMaximumSize(new java.awt.Dimension(37, 19));
        btnStartScenario.setMinimumSize(new java.awt.Dimension(37, 19));
        btnStartScenario.setPreferredSize(new java.awt.Dimension(37, 19));
        btnStartScenario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnStartScenarioActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 10));
        jLabel1.setText("Scenario List:");

        listScenarios.setFont(listScenarios.getFont().deriveFont(listScenarios.getFont().getStyle() & ~java.awt.Font.BOLD, listScenarios.getFont().getSize()-1));
        listScenarios.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Left Lane", "Middle Lane", "Right Lane" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        listScenarios.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        listScenarios.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                listScenariosValueChanged(evt);
            }
        });
        jScrollPane5.setViewportView(listScenarios);

        btnSwitchMode.setFont(btnSwitchMode.getFont().deriveFont(btnSwitchMode.getFont().getStyle() & ~java.awt.Font.BOLD, btnSwitchMode.getFont().getSize()-1));
        btnSwitchMode.setText("Mode");
        btnSwitchMode.setMaximumSize(new java.awt.Dimension(37, 19));
        btnSwitchMode.setMinimumSize(new java.awt.Dimension(37, 19));
        btnSwitchMode.setPreferredSize(new java.awt.Dimension(37, 19));
        btnSwitchMode.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnSwitchModeMouseClicked(evt);
            }
        });
        btnSwitchMode.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSwitchModeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout frmScenarioLayout = new javax.swing.GroupLayout(frmScenario);
        frmScenario.setLayout(frmScenarioLayout);
        frmScenarioLayout.setHorizontalGroup(
            frmScenarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frmScenarioLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(frmScenarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblScenarioName)
                    .addGroup(frmScenarioLayout.createSequentialGroup()
                        .addComponent(txtScenarioName, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnSwitchMode, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 164, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, frmScenarioLayout.createSequentialGroup()
                        .addGroup(frmScenarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(btnSave, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnCreateScenario, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)
                            .addComponent(lblClock, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnStartScenario, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(6, 6, 6)
                .addGroup(frmScenarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
            .addGroup(frmScenarioLayout.createSequentialGroup()
                .addGap(95, 95, 95)
                .addComponent(btnReplay, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(165, 165, 165))
            .addGroup(frmScenarioLayout.createSequentialGroup()
                .addGap(95, 95, 95)
                .addComponent(btnFinish)
                .addGap(165, 165, 165))
        );

        frmScenarioLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnCreateScenario, btnFinish, btnReplay, btnSave, btnStartScenario, lblClock});

        frmScenarioLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jScrollPane5});

        frmScenarioLayout.setVerticalGroup(
            frmScenarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frmScenarioLayout.createSequentialGroup()
                .addGroup(frmScenarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblClock, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(btnStartScenario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(frmScenarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(frmScenarioLayout.createSequentialGroup()
                        .addGroup(frmScenarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnCreateScenario, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnFinish, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(frmScenarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnReplay, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnSave, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblScenarioName)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(frmScenarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtScenarioName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnSwitchMode, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jScrollPane5))
                .addContainerGap())
        );

        frmScenarioLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {btnCreateScenario, btnFinish, btnReplay, btnSave, btnStartScenario, btnSwitchMode, lblClock});

        frmScene.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Scene", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12))); // NOI18N
        frmScene.setDoubleBuffered(false);
        frmScene.setFocusable(false);
        frmScene.setMaximumSize(new java.awt.Dimension(396, 768));
        frmScene.setMinimumSize(new java.awt.Dimension(396, 768));
        frmScene.setName("frmScene"); // NOI18N
        frmScene.setOpaque(false);
        frmScene.setPreferredSize(new java.awt.Dimension(396, 768));
        frmScene.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                frmSceneComponentResized(evt);
            }
        });
        frmScene.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                frmSceneMouseMoved(evt);
            }
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                frmSceneMouseDragged(evt);
            }
        });

        javax.swing.GroupLayout frmSceneLayout = new javax.swing.GroupLayout(frmScene);
        frmScene.setLayout(frmSceneLayout);
        frmSceneLayout.setHorizontalGroup(
            frmSceneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 388, Short.MAX_VALUE)
        );
        frmSceneLayout.setVerticalGroup(
            frmSceneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 645, Short.MAX_VALUE)
        );

        frmVehicle.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Vehicle", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12))); // NOI18N
        frmVehicle.setMaximumSize(new java.awt.Dimension(256, 312));
        frmVehicle.setMinimumSize(new java.awt.Dimension(32, 267));
        frmVehicle.setName("frmVehicle"); // NOI18N
        frmVehicle.setOpaque(false);
        frmVehicle.setPreferredSize(new java.awt.Dimension(256, 307));

        btnPreviousVehicle.setFont(btnPreviousVehicle.getFont().deriveFont(btnPreviousVehicle.getFont().getStyle() & ~java.awt.Font.BOLD, btnPreviousVehicle.getFont().getSize()-1));
        btnPreviousVehicle.setText("<");
        btnPreviousVehicle.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnPreviousVehicle.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btnPreviousVehicleMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                btnPreviousVehicleMouseExited(evt);
            }
        });
        btnPreviousVehicle.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPreviousVehicleActionPerformed(evt);
            }
        });

        imgVehicle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        imgVehicle.setAlignmentX(0.5F);
        imgVehicle.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        imgVehicle.setFocusable(false);
        imgVehicle.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        imgVehicle.setMaximumSize(new java.awt.Dimension(32, 32));
        imgVehicle.setMinimumSize(new java.awt.Dimension(32, 32));
        imgVehicle.setName("imgVehicle"); // NOI18N
        imgVehicle.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                imgVehicleMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                imgVehicleMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                imgVehicleMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                imgVehicleMouseReleased(evt);
            }
        });
        imgVehicle.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                imgVehicleMouseDragged(evt);
            }
        });

        btnNextVehicle.setFont(btnNextVehicle.getFont().deriveFont(btnNextVehicle.getFont().getStyle() & ~java.awt.Font.BOLD, btnNextVehicle.getFont().getSize()-1));
        btnNextVehicle.setText(">");
        btnNextVehicle.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btnNextVehicleMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                btnNextVehicleMouseExited(evt);
            }
        });
        btnNextVehicle.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNextVehicleActionPerformed(evt);
            }
        });

        sliderRotate.setFont(sliderRotate.getFont().deriveFont(sliderRotate.getFont().getStyle() & ~java.awt.Font.BOLD, sliderRotate.getFont().getSize()-1));
        sliderRotate.setMaximum(180);
        sliderRotate.setMinimum(-180);
        sliderRotate.setSnapToTicks(true);
        sliderRotate.setValue(0);
        sliderRotate.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Rotate Vehicle", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12))); // NOI18N
        sliderRotate.setExtent(1);
        sliderRotate.setMaximumSize(new java.awt.Dimension(180, 72));
        sliderRotate.setMinimumSize(new java.awt.Dimension(180, 72));
        sliderRotate.setPreferredSize(new java.awt.Dimension(180, 72));
        sliderRotate.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                sliderRotateMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                sliderRotateMouseReleased(evt);
            }
        });
        sliderRotate.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                sliderRotateStateChanged(evt);
            }
        });

        frmWheelAngle.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Wheel Angle", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12))); // NOI18N
        frmWheelAngle.setFont(frmWheelAngle.getFont().deriveFont(frmWheelAngle.getFont().getStyle() & ~java.awt.Font.BOLD, frmWheelAngle.getFont().getSize()-1));
        frmWheelAngle.setMaximumSize(new java.awt.Dimension(180, 72));
        frmWheelAngle.setMinimumSize(new java.awt.Dimension(180, 72));
        frmWheelAngle.setPreferredSize(new java.awt.Dimension(180, 72));
        frmWheelAngle.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                frmWheelAngleMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                frmWheelAngleMouseExited(evt);
            }
        });

        imgWheelAngle.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        imgWheelAngle.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                imgWheelAngleMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                imgWheelAngleMouseReleased(evt);
            }
        });
        imgWheelAngle.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                imgWheelAngleMouseDragged(evt);
            }
        });

        btnWheelAngleLeft.setFont(btnWheelAngleLeft.getFont().deriveFont(btnWheelAngleLeft.getFont().getStyle() & ~java.awt.Font.BOLD, btnWheelAngleLeft.getFont().getSize()-1));
        btnWheelAngleLeft.setText("<");
        btnWheelAngleLeft.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                btnWheelAngleLeftMousePressed(evt);
            }
        });
        btnWheelAngleLeft.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnWheelAngleLeftActionPerformed(evt);
            }
        });

        btnWheelAngleRight.setFont(btnWheelAngleRight.getFont().deriveFont(btnWheelAngleRight.getFont().getStyle() & ~java.awt.Font.BOLD, btnWheelAngleRight.getFont().getSize()-1));
        btnWheelAngleRight.setText(">");
        btnWheelAngleRight.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                btnWheelAngleRightMousePressed(evt);
            }
        });
        btnWheelAngleRight.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnWheelAngleRightActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout frmWheelAngleLayout = new javax.swing.GroupLayout(frmWheelAngle);
        frmWheelAngle.setLayout(frmWheelAngleLayout);
        frmWheelAngleLayout.setHorizontalGroup(
            frmWheelAngleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frmWheelAngleLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btnWheelAngleLeft)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(imgWheelAngle, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnWheelAngleRight)
                .addContainerGap(18, Short.MAX_VALUE))
        );

        frmWheelAngleLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnWheelAngleLeft, btnWheelAngleRight});

        frmWheelAngleLayout.setVerticalGroup(
            frmWheelAngleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frmWheelAngleLayout.createSequentialGroup()
                .addGroup(frmWheelAngleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnWheelAngleLeft, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(imgWheelAngle, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnWheelAngleRight, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        frmWheelAngleLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {btnWheelAngleLeft, btnWheelAngleRight});

        javax.swing.GroupLayout frmVehicleLayout = new javax.swing.GroupLayout(frmVehicle);
        frmVehicle.setLayout(frmVehicleLayout);
        frmVehicleLayout.setHorizontalGroup(
            frmVehicleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, frmVehicleLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(frmVehicleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(sliderRotate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(frmWheelAngle, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE)
                    .addGroup(frmVehicleLayout.createSequentialGroup()
                        .addComponent(btnPreviousVehicle)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(imgVehicle, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnNextVehicle)))
                .addContainerGap())
        );

        frmVehicleLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnNextVehicle, btnPreviousVehicle});

        frmVehicleLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {frmWheelAngle, sliderRotate});

        frmVehicleLayout.setVerticalGroup(
            frmVehicleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frmVehicleLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(frmVehicleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnPreviousVehicle, javax.swing.GroupLayout.DEFAULT_SIZE, 93, Short.MAX_VALUE)
                    .addComponent(imgVehicle, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnNextVehicle, javax.swing.GroupLayout.DEFAULT_SIZE, 93, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(sliderRotate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(frmWheelAngle, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        frmVehicleLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {btnNextVehicle, btnPreviousVehicle});

        imgVehicle.getAccessibleContext().setAccessibleName("imgVehicle");

        frmChat.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Communication", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12))); // NOI18N
        frmChat.setMaximumSize(new java.awt.Dimension(365, 178));
        frmChat.setName("frmChat"); // NOI18N
        frmChat.setOpaque(false);
        frmChat.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                frmChatMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                frmChatMouseExited(evt);
            }
        });

        txtboxChat.setColumns(20);
        txtboxChat.setFont(new java.awt.Font("Monospaced", 0, 12));
        txtboxChat.setLineWrap(true);
        txtboxChat.setRows(5);
        txtboxChat.setWrapStyleWord(true);
        txtboxChat.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        txtboxChat.setFocusable(false);
        txtboxChat.setName("txtboxChat"); // NOI18N
        txtboxChat.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                txtboxChatMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                txtboxChatMouseExited(evt);
            }
        });
        jScrollPane1.setViewportView(txtboxChat);

        txtTypeMessage.setFont(new java.awt.Font("Tahoma", 0, 12));
        txtTypeMessage.setText("Type Message Here...");
        txtTypeMessage.setName("txtTypeMessage"); // NOI18N
        txtTypeMessage.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                txtTypeMessageMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                txtTypeMessageMouseExited(evt);
            }
        });
        txtTypeMessage.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtTypeMessageActionPerformed(evt);
            }
        });
        txtTypeMessage.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtTypeMessageFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtTypeMessageFocusLost(evt);
            }
        });
        txtTypeMessage.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtTypeMessageKeyPressed(evt);
            }
        });

        btnSendMessage.setFont(btnSendMessage.getFont().deriveFont(btnSendMessage.getFont().getStyle() & ~java.awt.Font.BOLD, btnSendMessage.getFont().getSize()-1));
        btnSendMessage.setText("Send Message");
        btnSendMessage.setName("btnSendMessage"); // NOI18N
        btnSendMessage.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnSendMessageMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btnSendMessageMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                btnSendMessageMouseExited(evt);
            }
        });
        btnSendMessage.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSendMessageActionPerformed(evt);
            }
        });

        comboRequest.setFont(new java.awt.Font("Tahoma", 0, 10));
        comboRequest.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Request Additional Vehicle" }));
        comboRequest.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                comboRequestItemStateChanged(evt);
            }
        });

        btnSendRequest.setFont(new java.awt.Font("Tahoma", 0, 10));
        btnSendRequest.setText("Send Request");
        btnSendRequest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSendRequestActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout frmChatLayout = new javax.swing.GroupLayout(frmChat);
        frmChat.setLayout(frmChatLayout);
        frmChatLayout.setHorizontalGroup(
            frmChatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, frmChatLayout.createSequentialGroup()
                .addGroup(frmChatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 339, Short.MAX_VALUE)
                    .addGroup(frmChatLayout.createSequentialGroup()
                        .addGroup(frmChatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(comboRequest, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtTypeMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(frmChatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btnSendRequest, 0, 0, Short.MAX_VALUE)
                            .addComponent(btnSendMessage))))
                .addContainerGap())
        );
        frmChatLayout.setVerticalGroup(
            frmChatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frmChatLayout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(frmChatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtTypeMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnSendMessage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(9, 9, 9)
                .addGroup(frmChatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboRequest, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnSendRequest, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        txtTypeMessage.getAccessibleContext().setAccessibleName("txtTypeMessage");

        frmResponders.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Responders", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12))); // NOI18N
        frmResponders.setName("frmResponders"); // NOI18N
        frmResponders.setOpaque(false);
        frmResponders.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                frmRespondersMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                frmRespondersMouseExited(evt);
            }
        });

        lblPolice.setFont(lblPolice.getFont().deriveFont(lblPolice.getFont().getStyle() & ~java.awt.Font.BOLD, lblPolice.getFont().getSize()-1));
        lblPolice.setText("Police: ");

        lblResponder4.setFont(lblResponder4.getFont().deriveFont(lblResponder4.getFont().getStyle() & ~java.awt.Font.BOLD, lblResponder4.getFont().getSize()-1));
        lblResponder4.setText("IDOT's Name");

        lblResponder3.setFont(lblResponder3.getFont().deriveFont(lblResponder3.getFont().getStyle() & ~java.awt.Font.BOLD, lblResponder3.getFont().getSize()-1));
        lblResponder3.setText("EMS' Name");

        lblResponder2.setFont(lblResponder2.getFont().deriveFont(lblResponder2.getFont().getStyle() & ~java.awt.Font.BOLD, lblResponder2.getFont().getSize()-1));
        lblResponder2.setText("Fireman's Name");

        lblResponder1.setFont(lblResponder1.getFont().deriveFont(lblResponder1.getFont().getStyle() & ~java.awt.Font.BOLD, lblResponder1.getFont().getSize()-1));
        lblResponder1.setText("Policeman's Name");

        btnEmsResponder.setFont(btnEmsResponder.getFont().deriveFont(btnEmsResponder.getFont().getStyle() & ~java.awt.Font.BOLD, btnEmsResponder.getFont().getSize()-1));
        btnEmsResponder.setText("Stop");
        btnEmsResponder.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btnEmsResponderMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                btnEmsResponderMouseExited(evt);
            }
        });
        btnEmsResponder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEmsResponderActionPerformed(evt);
            }
        });

        lblFire.setFont(lblFire.getFont().deriveFont(lblFire.getFont().getStyle() & ~java.awt.Font.BOLD, lblFire.getFont().getSize()-1));
        lblFire.setText("Fire: ");

        lblEMS.setFont(lblEMS.getFont().deriveFont(lblEMS.getFont().getStyle() & ~java.awt.Font.BOLD, lblEMS.getFont().getSize()-1));
        lblEMS.setText("E.M.S: ");

        lblIDOT.setFont(lblIDOT.getFont().deriveFont(lblIDOT.getFont().getStyle() & ~java.awt.Font.BOLD, lblIDOT.getFont().getSize()-1));
        lblIDOT.setText("Service Patrol:");

        btnPoliceResponder.setFont(btnPoliceResponder.getFont().deriveFont(btnPoliceResponder.getFont().getStyle() & ~java.awt.Font.BOLD, btnPoliceResponder.getFont().getSize()-1));
        btnPoliceResponder.setText("Stop");
        btnPoliceResponder.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnPoliceResponderMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btnPoliceResponderMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                btnPoliceResponderMouseExited(evt);
            }
        });
        btnPoliceResponder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPoliceResponderActionPerformed(evt);
            }
        });

        btnIdotResponder.setFont(btnIdotResponder.getFont().deriveFont(btnIdotResponder.getFont().getStyle() & ~java.awt.Font.BOLD, btnIdotResponder.getFont().getSize()-1));
        btnIdotResponder.setText("Stop");
        btnIdotResponder.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btnIdotResponderMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                btnIdotResponderMouseExited(evt);
            }
        });
        btnIdotResponder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnIdotResponderActionPerformed(evt);
            }
        });

        btnFireResponder.setFont(btnFireResponder.getFont().deriveFont(btnFireResponder.getFont().getStyle() & ~java.awt.Font.BOLD, btnFireResponder.getFont().getSize()-1));
        btnFireResponder.setText("Stop");
        btnFireResponder.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btnFireResponderMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                btnFireResponderMouseExited(evt);
            }
        });
        btnFireResponder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFireResponderActionPerformed(evt);
            }
        });

        lblTow.setFont(lblTow.getFont().deriveFont(lblTow.getFont().getStyle() & ~java.awt.Font.BOLD, lblTow.getFont().getSize()-1));
        lblTow.setText("Tow Truck:");

        lblResponder5.setFont(lblResponder5.getFont().deriveFont(lblResponder5.getFont().getStyle() & ~java.awt.Font.BOLD, lblResponder5.getFont().getSize()-1));
        lblResponder5.setText("Tow Truck Driver's Name");

        btnTowResponder.setFont(btnTowResponder.getFont().deriveFont(btnTowResponder.getFont().getStyle() & ~java.awt.Font.BOLD, btnTowResponder.getFont().getSize()-1));
        btnTowResponder.setText("Stop");
        btnTowResponder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTowResponderActionPerformed(evt);
            }
        });

        lblVictim.setFont(lblVictim.getFont().deriveFont(lblVictim.getFont().getStyle() & ~java.awt.Font.BOLD, lblVictim.getFont().getSize()-1));
        lblVictim.setText("Victim:");

        lblVictimName.setFont(lblVictimName.getFont().deriveFont(lblVictimName.getFont().getStyle() & ~java.awt.Font.BOLD, lblVictimName.getFont().getSize()-1));
        lblVictimName.setText("Victim's Name");

        btnVictimResponder.setFont(btnVictimResponder.getFont().deriveFont(btnVictimResponder.getFont().getStyle() & ~java.awt.Font.BOLD, btnVictimResponder.getFont().getSize()-1));
        btnVictimResponder.setText("Stop");
        btnVictimResponder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnVictimResponderActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout frmRespondersLayout = new javax.swing.GroupLayout(frmResponders);
        frmResponders.setLayout(frmRespondersLayout);
        frmRespondersLayout.setHorizontalGroup(
            frmRespondersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frmRespondersLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(frmRespondersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblVictim)
                    .addComponent(lblTow)
                    .addComponent(lblIDOT)
                    .addComponent(lblEMS, javax.swing.GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE)
                    .addComponent(lblFire, javax.swing.GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE)
                    .addComponent(lblPolice))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(frmRespondersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(lblResponder1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 138, Short.MAX_VALUE)
                    .addComponent(lblResponder2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lblResponder3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lblResponder4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lblResponder5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lblVictimName, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(frmRespondersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnPoliceResponder, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnFireResponder, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnEmsResponder, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnIdotResponder, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnTowResponder, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnVictimResponder, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        frmRespondersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnEmsResponder, btnFireResponder, btnIdotResponder, btnPoliceResponder, btnTowResponder, btnVictimResponder});

        frmRespondersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {lblEMS, lblFire, lblIDOT, lblPolice, lblTow, lblVictim});

        frmRespondersLayout.setVerticalGroup(
            frmRespondersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frmRespondersLayout.createSequentialGroup()
                .addGroup(frmRespondersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblResponder1)
                    .addComponent(lblPolice)
                    .addComponent(btnPoliceResponder))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(frmRespondersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblFire)
                    .addComponent(lblResponder2)
                    .addComponent(btnFireResponder))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(frmRespondersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblEMS)
                    .addComponent(lblResponder3)
                    .addComponent(btnEmsResponder))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(frmRespondersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblIDOT)
                    .addComponent(lblResponder4)
                    .addComponent(btnIdotResponder))
                .addGap(6, 6, 6)
                .addGroup(frmRespondersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblResponder5)
                    .addComponent(btnTowResponder)
                    .addComponent(lblTow))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(frmRespondersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblVictim)
                    .addComponent(lblVictimName)
                    .addComponent(btnVictimResponder))
                .addContainerGap())
        );

        frmHelp.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Help", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12))); // NOI18N
        frmHelp.setName("frmHelp"); // NOI18N
        frmHelp.setOpaque(false);
        frmHelp.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                frmHelpMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                frmHelpMouseExited(evt);
            }
        });

        lblDirections.setColumns(20);
        lblDirections.setEditable(false);
        lblDirections.setFont(new java.awt.Font("Tahoma", 1, 10));
        lblDirections.setLineWrap(true);
        lblDirections.setRows(3);
        lblDirections.setWrapStyleWord(true);
        lblDirections.setBorder(null);
        lblDirections.setFocusable(false);
        lblDirections.setMaximumSize(new java.awt.Dimension(100, 13));
        lblDirections.setOpaque(false);
        lblDirections.setPreferredSize(new java.awt.Dimension(100, 13));
        jScrollPane2.setViewportView(lblDirections);

        lblHelp.setColumns(20);
        lblHelp.setEditable(false);
        lblHelp.setFont(new java.awt.Font("Tahoma", 0, 10));
        lblHelp.setLineWrap(true);
        lblHelp.setRows(3);
        lblHelp.setWrapStyleWord(true);
        lblHelp.setBorder(null);
        lblHelp.setFocusable(false);
        lblHelp.setMaximumSize(new java.awt.Dimension(100, 13));
        lblHelp.setOpaque(false);
        lblHelp.setPreferredSize(new java.awt.Dimension(100, 13));
        jScrollPane3.setViewportView(lblHelp);

        javax.swing.GroupLayout frmHelpLayout = new javax.swing.GroupLayout(frmHelp);
        frmHelp.setLayout(frmHelpLayout);
        frmHelpLayout.setHorizontalGroup(
            frmHelpLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 209, Short.MAX_VALUE)
            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 209, Short.MAX_VALUE)
        );

        frmHelpLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jScrollPane2, jScrollPane3});

        frmHelpLayout.setVerticalGroup(
            frmHelpLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frmHelpLayout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        frmHelpLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jScrollPane2, jScrollPane3});

        frmItems.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Traffic Control Devices", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12))); // NOI18N
        frmItems.setMaximumSize(new java.awt.Dimension(256, 146));
        frmItems.setMinimumSize(new java.awt.Dimension(256, 146));
        frmItems.setName("frmItems"); // NOI18N
        frmItems.setOpaque(false);
        frmItems.setPreferredSize(new java.awt.Dimension(100, 317));
        frmItems.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                frmItemsMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                frmItemsMouseExited(evt);
            }
        });

        item0Label.setFont(item0Label.getFont().deriveFont(item0Label.getFont().getSize()-4f));
        item0Label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        item0Label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/cone_50x50.png"))); // NOI18N
        item0Label.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        item0Label.setFocusable(false);
        item0Label.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        item0Label.setMaximumSize(new java.awt.Dimension(48, 48));
        item0Label.setMinimumSize(new java.awt.Dimension(48, 48));
        item0Label.setPreferredSize(new java.awt.Dimension(48, 48));
        item0Label.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                item0LabelMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                item0LabelMouseReleased(evt);
            }
        });
        item0Label.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                item0LabelMouseDragged(evt);
            }
        });

        lblItem0Count.setFont(lblItem0Count.getFont().deriveFont(lblItem0Count.getFont().getStyle() & ~java.awt.Font.BOLD, lblItem0Count.getFont().getSize()-1));
        lblItem0Count.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        lblItem0Count.setMaximumSize(new java.awt.Dimension(48, 48));
        lblItem0Count.setPreferredSize(new java.awt.Dimension(48, 15));
        lblItem0Count.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                lblItem0CountKeyPressed(evt);
            }
        });

        lblItem0Name.setFont(lblItem0Name.getFont().deriveFont(lblItem0Name.getFont().getStyle() & ~java.awt.Font.BOLD, lblItem0Name.getFont().getSize()-1));
        lblItem0Name.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblItem0Name.setText("Cones");
        lblItem0Name.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        lblItem0Name.setMaximumSize(new java.awt.Dimension(48, 13));
        lblItem0Name.setMinimumSize(new java.awt.Dimension(48, 13));
        lblItem0Name.setPreferredSize(new java.awt.Dimension(48, 12));

        item1Label.setFont(item1Label.getFont().deriveFont(item1Label.getFont().getSize()-4f));
        item1Label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        item1Label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/safetysign_50x50.png"))); // NOI18N
        item1Label.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        item1Label.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        item1Label.setMaximumSize(new java.awt.Dimension(48, 48));
        item1Label.setMinimumSize(new java.awt.Dimension(48, 48));
        item1Label.setPreferredSize(new java.awt.Dimension(48, 48));
        item1Label.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                item1LabelMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                item1LabelMouseReleased(evt);
            }
        });
        item1Label.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                item1LabelMouseDragged(evt);
            }
        });

        lblItem1Count.setFont(lblItem1Count.getFont().deriveFont(lblItem1Count.getFont().getStyle() & ~java.awt.Font.BOLD, lblItem1Count.getFont().getSize()-1));
        lblItem1Count.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        lblItem1Count.setMaximumSize(new java.awt.Dimension(48, 48));
        lblItem1Count.setMinimumSize(new java.awt.Dimension(48, 15));
        lblItem1Count.setPreferredSize(new java.awt.Dimension(48, 15));
        lblItem1Count.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                lblItem1CountKeyPressed(evt);
            }
        });

        item2Label.setFont(item2Label.getFont().deriveFont(item2Label.getFont().getSize()-4f));
        item2Label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        item2Label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/drum_50x50.png"))); // NOI18N
        item2Label.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        item2Label.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        item2Label.setMaximumSize(new java.awt.Dimension(48, 48));
        item2Label.setMinimumSize(new java.awt.Dimension(48, 48));
        item2Label.setPreferredSize(new java.awt.Dimension(48, 48));
        item2Label.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                item2LabelMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                item2LabelMouseReleased(evt);
            }
        });
        item2Label.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                item2LabelMouseDragged(evt);
            }
        });

        lblItem2Count.setFont(lblItem2Count.getFont().deriveFont(lblItem2Count.getFont().getStyle() & ~java.awt.Font.BOLD, lblItem2Count.getFont().getSize()-1));
        lblItem2Count.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        lblItem2Count.setMaximumSize(new java.awt.Dimension(48, 48));
        lblItem2Count.setMinimumSize(new java.awt.Dimension(48, 15));
        lblItem2Count.setPreferredSize(new java.awt.Dimension(48, 15));
        lblItem2Count.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                lblItem2CountKeyPressed(evt);
            }
        });

        item3Label.setFont(item3Label.getFont().deriveFont(item3Label.getFont().getSize()-4f));
        item3Label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        item3Label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/flares_50x50.png"))); // NOI18N
        item3Label.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        item3Label.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        item3Label.setMaximumSize(new java.awt.Dimension(48, 48));
        item3Label.setMinimumSize(new java.awt.Dimension(48, 48));
        item3Label.setPreferredSize(new java.awt.Dimension(48, 48));
        item3Label.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                item3LabelMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                item3LabelMouseReleased(evt);
            }
        });
        item3Label.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                item3LabelMouseDragged(evt);
            }
        });

        lblItem3Count.setFont(lblItem3Count.getFont().deriveFont(lblItem3Count.getFont().getStyle() & ~java.awt.Font.BOLD, lblItem3Count.getFont().getSize()-1));
        lblItem3Count.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        lblItem3Count.setMaximumSize(new java.awt.Dimension(48, 48));
        lblItem3Count.setMinimumSize(new java.awt.Dimension(48, 15));
        lblItem3Count.setPreferredSize(new java.awt.Dimension(48, 15));
        lblItem3Count.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                lblItem3CountKeyPressed(evt);
            }
        });

        lblItem1Name.setFont(lblItem1Name.getFont().deriveFont(lblItem1Name.getFont().getStyle() & ~java.awt.Font.BOLD, lblItem1Name.getFont().getSize()-1));
        lblItem1Name.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblItem1Name.setText("Sign");
        lblItem1Name.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        lblItem2Name.setFont(lblItem2Name.getFont().deriveFont(lblItem2Name.getFont().getStyle() & ~java.awt.Font.BOLD, lblItem2Name.getFont().getSize()-1));
        lblItem2Name.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblItem2Name.setText("Drum");
        lblItem2Name.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        lblItem2Name.setMinimumSize(new java.awt.Dimension(48, 13));
        lblItem2Name.setPreferredSize(new java.awt.Dimension(48, 13));

        lblItem3Name.setFont(lblItem3Name.getFont().deriveFont(lblItem3Name.getFont().getStyle() & ~java.awt.Font.BOLD, lblItem3Name.getFont().getSize()-1));
        lblItem3Name.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblItem3Name.setText("Flare");
        lblItem3Name.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        lblItem3Name.setMaximumSize(new java.awt.Dimension(48, 13));
        lblItem3Name.setPreferredSize(new java.awt.Dimension(48, 13));

        javax.swing.GroupLayout frmItemsLayout = new javax.swing.GroupLayout(frmItems);
        frmItems.setLayout(frmItemsLayout);
        frmItemsLayout.setHorizontalGroup(
            frmItemsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frmItemsLayout.createSequentialGroup()
                .addGroup(frmItemsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(item0Label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lblItem0Name, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lblItem0Count, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(frmItemsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(item1Label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lblItem1Name, javax.swing.GroupLayout.DEFAULT_SIZE, 48, Short.MAX_VALUE)
                    .addComponent(lblItem1Count, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(frmItemsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(item2Label, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblItem2Name, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lblItem2Count, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(frmItemsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(frmItemsLayout.createSequentialGroup()
                        .addGap(6, 6, 6)
                        .addGroup(frmItemsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(lblItem3Name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblItem3Count, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(frmItemsLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(item3Label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );

        frmItemsLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {item3Label, lblItem3Count, lblItem3Name});

        frmItemsLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {item1Label, lblItem1Count, lblItem1Name});

        frmItemsLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {item2Label, lblItem2Count, lblItem2Name});

        frmItemsLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {item0Label, lblItem0Count, lblItem0Name});

        frmItemsLayout.setVerticalGroup(
            frmItemsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frmItemsLayout.createSequentialGroup()
                .addGroup(frmItemsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(frmItemsLayout.createSequentialGroup()
                        .addComponent(item3Label, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblItem3Name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblItem3Count, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(frmItemsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(frmItemsLayout.createSequentialGroup()
                            .addComponent(item1Label, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(lblItem1Name, javax.swing.GroupLayout.PREFERRED_SIZE, 13, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(lblItem1Count, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(frmItemsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(frmItemsLayout.createSequentialGroup()
                                .addComponent(item2Label, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblItem2Name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblItem2Count, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(frmItemsLayout.createSequentialGroup()
                                .addComponent(item0Label, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblItem0Name, javax.swing.GroupLayout.PREFERRED_SIZE, 13, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblItem0Count, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        frmItemsLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {lblItem0Count, lblItem1Count, lblItem2Count, lblItem3Count});

        frmItemsLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {item0Label, item1Label, item2Label, item3Label});

        frmItemsLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {lblItem0Name, lblItem1Name, lblItem2Name, lblItem3Name});

        item0Label.getAccessibleContext().setAccessibleName("iventoryItem0");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(frmChat, 0, 356, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(frmScenario, javax.swing.GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE)
                        .addComponent(frmResponders, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(frmScene, javax.swing.GroupLayout.PREFERRED_SIZE, 404, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(frmItems, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(frmVehicle, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(frmHelp, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {frmChat, frmResponders, frmScenario});

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {frmHelp, frmItems, frmVehicle});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(frmScene, javax.swing.GroupLayout.Alignment.LEADING, 0, 676, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(frmScenario, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(frmResponders, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(frmChat, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(frmItems, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(frmVehicle, javax.swing.GroupLayout.PREFERRED_SIZE, 313, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(frmHelp, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGap(16, 16, 16))
        );

        frmScenario.getAccessibleContext().setAccessibleName("frmScenario");
        frmScene.getAccessibleContext().setAccessibleName("frmScene");
        frmVehicle.getAccessibleContext().setAccessibleName("frmVehicle");
        frmChat.getAccessibleContext().setAccessibleName("frmChat");
        frmResponders.getAccessibleContext().setAccessibleName("frmResponders");
        frmHelp.getAccessibleContext().setAccessibleName("frmHelp");
        frmItems.getAccessibleContext().setAccessibleName("frmItems");
    }// </editor-fold>//GEN-END:initComponents

   /**
    * Sets the help-section in the Help Window to display what the Help Window does.
    * 
    * @author Tim Pruitt
    *
    * @param  evt The event of the mouse entering frmHelp
    */
    private void frmHelpMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_frmHelpMouseEntered
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.HELP_WINDOW]);
    }//GEN-LAST:event_frmHelpMouseEntered

   /**
    * Clears the prompt in the text box so a message can be typed immediately.
    * 
    * @author Tim Pruitt
    *
    * @param  evt The event of the mouse entering txtTypeMessage
    */
    private void txtTypeMessageFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtTypeMessageFocusGained
        if (txtTypeMessage.getText().equals(GUIPrompts.MESSAGE_INSERT_TEXT))
        {
            txtTypeMessage.setText("");
        }
    }//GEN-LAST:event_txtTypeMessageFocusGained

     /**
     * If a message is not typed, the prompt reappears in the text box.
     *
     * @author tpruitt
     */
    private void txtTypeMessageFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtTypeMessageFocusLost
        if (txtTypeMessage.getText().equals(""))
        {
            txtTypeMessage.setText(GUIPrompts.MESSAGE_INSERT_TEXT);
        }
    }//GEN-LAST:event_txtTypeMessageFocusLost

    private void btnSendMessageMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnSendMessageMouseClicked
        // TODO add your handling code here:
        sendMessage();
    }//GEN-LAST:event_btnSendMessageMouseClicked

    public void WriteChatMessage(String message)
    {
        txtboxChat.append(message + "\n");
    }
    public void WriteRequestMessage(String message)
    {
        txtboxChat.setForeground(Color.red);
        txtboxChat.append(message + "\n");
        txtboxChat.setForeground(Color.black);
    }

    /**
     * Sends the typed message to the local client and resets the text box.
     *
     * @author Tim Pruitt
     */
    private void sendMessage()
    {
        if ( !(txtTypeMessage.getText().equals("Type Message Here...") ||
                txtTypeMessage.getText().equals("")) )
        {
            mainFrame.client.sendChatMessage(txtTypeMessage.getText());
            txtTypeMessage.setText("Type Message Here...");

            // Fixes clearing the message
            txtTypeMessage.setFocusable(false);
            txtTypeMessage.setFocusable(true);
            txtTypeMessage.grabFocus();

            this.displayDirections( Feedback.SENT_MESSAGE );

            txtboxChat.setCaretPosition( txtboxChat.getDocument().getLength() );
        }
    }

    /**
     * Enables a message to be send thru hitting the enter button.
     *
     * @author Tim Pruitt
     *
     * @param evt Only performs an action if the event is the enter-key
     *  being pressed.
     */
    private void txtTypeMessageKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtTypeMessageKeyPressed
        if (evt.getKeyCode()==10)
        {
            sendMessage();
        }
    }//GEN-LAST:event_txtTypeMessageKeyPressed

     /**
     * Displays a help message in the Help Window on what the clock does.
     *
     * @author tpruitt
     */
    private void lblClockMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblClockMouseEntered
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CLOCK]);
    }//GEN-LAST:event_lblClockMouseEntered

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void lblClockMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblClockMouseExited
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CLEAR_HELP ]);
    }//GEN-LAST:event_lblClockMouseExited

    private void frmRespondersMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_frmRespondersMouseEntered
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.RESPONDERS]);
    }//GEN-LAST:event_frmRespondersMouseEntered

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void frmRespondersMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_frmRespondersMouseExited
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CLEAR_HELP]);
    }//GEN-LAST:event_frmRespondersMouseExited

    private void txtboxChatMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_txtboxChatMouseEntered
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.MESSAGES]);
    }//GEN-LAST:event_txtboxChatMouseEntered

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void txtboxChatMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_txtboxChatMouseExited
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CLEAR_HELP]);
    }//GEN-LAST:event_txtboxChatMouseExited

    private void txtTypeMessageMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_txtTypeMessageMouseEntered
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.TYPING_MESSAGE]);
    }//GEN-LAST:event_txtTypeMessageMouseEntered

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void txtTypeMessageMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_txtTypeMessageMouseExited
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CLEAR_HELP]);
    }//GEN-LAST:event_txtTypeMessageMouseExited

    private void btnSendMessageMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnSendMessageMouseEntered
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.SEND_MESSAGE]);
    }//GEN-LAST:event_btnSendMessageMouseEntered

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void btnSendMessageMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnSendMessageMouseExited
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CLEAR_HELP]);
    }//GEN-LAST:event_btnSendMessageMouseExited

    private void txtTypeMessageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTypeMessageActionPerformed

    }//GEN-LAST:event_txtTypeMessageActionPerformed

    private void frmChatMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_frmChatMouseEntered
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.MESSAGES]);
    }//GEN-LAST:event_frmChatMouseEntered

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void frmChatMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_frmChatMouseExited
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CLEAR_HELP]);
    }//GEN-LAST:event_frmChatMouseExited

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void btnCreateScenarioMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCreateScenarioMouseEntered
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CREATE_SCENARIO]);
    }//GEN-LAST:event_btnCreateScenarioMouseEntered

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void btnCreateScenarioMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCreateScenarioMouseExited
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CLEAR_HELP]);
    }//GEN-LAST:event_btnCreateScenarioMouseExited

    private void frmItemsMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_frmItemsMouseEntered
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.ITEMS]);
    }//GEN-LAST:event_frmItemsMouseEntered

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void frmItemsMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_frmItemsMouseExited
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CLEAR_HELP]);
    }//GEN-LAST:event_frmItemsMouseExited

    private void imgVehicleMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_imgVehicleMouseEntered
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.VEHICLE_ORIENTATION]);
    }//GEN-LAST:event_imgVehicleMouseEntered

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void imgVehicleMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_imgVehicleMouseExited
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CLEAR_HELP]);
    }//GEN-LAST:event_imgVehicleMouseExited

    private void frmWheelAngleMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_frmWheelAngleMouseEntered
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.WHEEL_ANGLE]);
    }//GEN-LAST:event_frmWheelAngleMouseEntered

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void frmWheelAngleMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_frmWheelAngleMouseExited
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CLEAR_HELP]);
    }//GEN-LAST:event_frmWheelAngleMouseExited

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void btnPreviousVehicleMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnPreviousVehicleMouseEntered
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.PREVIOUS_VEHICLE]);
    }//GEN-LAST:event_btnPreviousVehicleMouseEntered

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void btnPreviousVehicleMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnPreviousVehicleMouseExited
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CLEAR_HELP]);
    }//GEN-LAST:event_btnPreviousVehicleMouseExited

    private void btnNextVehicleMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnNextVehicleMouseEntered
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.NEXT_VEHICLE]);
    }//GEN-LAST:event_btnNextVehicleMouseEntered

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void btnNextVehicleMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnNextVehicleMouseExited
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CLEAR_HELP]);
    }//GEN-LAST:event_btnNextVehicleMouseExited

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void frmHelpMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_frmHelpMouseExited
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CLEAR_HELP]);
    }//GEN-LAST:event_frmHelpMouseExited

    private void btnSendMessageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSendMessageActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnSendMessageActionPerformed

    private void btnCreateScenarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCreateScenarioActionPerformed
        
        try {
            refreshResponders();
        } catch (Exception ex) {
            Logger.getLogger(MainScreenPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btnCreateScenarioActionPerformed

    private void btnPreviousVehicleActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPreviousVehicleActionPerformed
    {//GEN-HEADEREND:event_btnPreviousVehicleActionPerformed
        localPlayer = client.getLocalPlayer();

        localPlayer.previousCar();

        refreshVehicle();
        refreshItems();

        this.displayDirections( Feedback.PREVIOUS_CAR );
    }//GEN-LAST:event_btnPreviousVehicleActionPerformed

    private void btnNextVehicleActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnNextVehicleActionPerformed
    {//GEN-HEADEREND:event_btnNextVehicleActionPerformed
        localPlayer = client.getLocalPlayer();

        localPlayer.nextCar();

        refreshVehicle();
        refreshItems();

        this.displayDirections( Feedback.NEXT_CAR );
    }//GEN-LAST:event_btnNextVehicleActionPerformed

    private void btnPoliceResponderMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnPoliceResponderMouseEntered
        if ( btnPoliceResponder.getText().equals(ADD_ROLE) ) {
            this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.RESPONDER_POLICE_JOIN]);
        }
        else if ( btnPoliceResponder.getText().equals(DROP_ROLE) ) {
            this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.RESPONDER_POLICE_DROP]);
        }
    }//GEN-LAST:event_btnPoliceResponderMouseEntered

    private void btnFireResponderMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnFireResponderMouseEntered
        if ( btnFireResponder.getText().equals(ADD_ROLE) ) {
            this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.RESPONDER_FIRE_JOIN]);
        }
        else if ( btnFireResponder.getText().equals(DROP_ROLE) ) {
            this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.RESPONDER_FIRE_DROP]);
        }
    }//GEN-LAST:event_btnFireResponderMouseEntered

    private void btnEmsResponderMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnEmsResponderMouseEntered
        if ( btnEmsResponder.getText().equals(ADD_ROLE) ) {
            this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.RESPONDER_EMS_JOIN]);
        }
        else if ( btnEmsResponder.getText().equals(DROP_ROLE) ) {
            this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.RESPONDER_EMS_DROP]);
        }
    }//GEN-LAST:event_btnEmsResponderMouseEntered

    private void btnIdotResponderMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnIdotResponderMouseEntered
        if ( btnIdotResponder.getText().equals(ADD_ROLE) ) {
            this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.RESPONDER_IDOT_JOIN]);
        }
        else if ( btnIdotResponder.getText().equals(DROP_ROLE) ) {
            this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.RESPONDER_IDOT_DROP]);
        }
    }//GEN-LAST:event_btnIdotResponderMouseEntered

    private void btnPoliceResponderMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnPoliceResponderMouseClicked
        
    }//GEN-LAST:event_btnPoliceResponderMouseClicked

    /**
     * Based on the local player playing/not playing a role, this method adds
     *  or drops the given role.
     *
     * @author Tim Pruitt
     *
     * @param button The corresponding responder button that was clicked.
     * @param roleIndex The role index of the responder button that was
     *  clicked.
     */
    private void playOrStopRole(JButton button, int roleIndex){
        if (button.getText().equals(DROP_ROLE))
        {
            try {
                client.removeRole(roleIndex);
            } catch (Exception ex) {
                System.out.println("Cannot drop the " + Role.getRoleName(roleIndex) + " role.");
            }
        }
        else if (button.getText().equals(ADD_ROLE))
        {
            client.addRole(roleIndex);
        }
    }

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void btnPoliceResponderMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnPoliceResponderMouseExited
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CLEAR_HELP]);
    }//GEN-LAST:event_btnPoliceResponderMouseExited

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void btnFireResponderMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnFireResponderMouseExited
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CLEAR_HELP]);
    }//GEN-LAST:event_btnFireResponderMouseExited

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void btnEmsResponderMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnEmsResponderMouseExited
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CLEAR_HELP]);
    }//GEN-LAST:event_btnEmsResponderMouseExited

    /**
     * Clears the help message in the Help Window
     *
     * @author tpruitt
     */
    private void btnIdotResponderMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnIdotResponderMouseExited
        this.lblHelp.setText(Feedback.HELP_MESSAGES[Feedback.CLEAR_HELP]);
    }//GEN-LAST:event_btnIdotResponderMouseExited

    private void frmRequestToComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_frmRequestToComponentShown
        // TODO add your handling code here:
    }//GEN-LAST:event_frmRequestToComponentShown

    private void dialogRequestComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_dialogRequestComponentShown

    }//GEN-LAST:event_dialogRequestComponentShown

    /**
     * Loads the selected scenario.
     *
     * @author Tim Pruitt
     * @param evt The event of btnStartScenario being selected.
     */
    private void btnStartScenarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStartScenarioActionPerformed
        Object tempObject = listScenarios.getSelectedValue();

        // Make sure something is actually selected before trying to get the corresponding string.
        if( tempObject != null )
        {
            String scenario = tempObject.toString();
            client.sendLoadScenario(scenario);
        }
    }//GEN-LAST:event_btnStartScenarioActionPerformed

    private void btnRequestMoveCarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnRequestMoveCarMouseClicked

    }//GEN-LAST:event_btnRequestMoveCarMouseClicked

    private void btnCancelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCancelMouseClicked

    }//GEN-LAST:event_btnCancelMouseClicked

    private void dialogRequestFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_dialogRequestFocusLost

    }//GEN-LAST:event_dialogRequestFocusLost

    private void btnRequestMoveConeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnRequestMoveConeMouseClicked

    }//GEN-LAST:event_btnRequestMoveConeMouseClicked

    private void btnRequestMoveSignMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnRequestMoveSignMouseClicked

    }//GEN-LAST:event_btnRequestMoveSignMouseClicked

    private void radioBtnPoliceFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_radioBtnPoliceFocusGained
        
    }//GEN-LAST:event_radioBtnPoliceFocusGained

    private void radioBtnFireFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_radioBtnFireFocusGained

    }//GEN-LAST:event_radioBtnFireFocusGained

    private void radioBtnEmsFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_radioBtnEmsFocusGained

    }//GEN-LAST:event_radioBtnEmsFocusGained

    private void radioBtnIdotFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_radioBtnIdotFocusGained

    }//GEN-LAST:event_radioBtnIdotFocusGained

    private void radioBtnPoliceMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_radioBtnPoliceMouseClicked
        frmRequests.setVisible(true);
    }//GEN-LAST:event_radioBtnPoliceMouseClicked

    private void radioBtnFireMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_radioBtnFireMouseClicked
        frmRequests.setVisible(true);
    }//GEN-LAST:event_radioBtnFireMouseClicked

    private void radioBtnEmsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_radioBtnEmsMouseClicked
        frmRequests.setVisible(true);
    }//GEN-LAST:event_radioBtnEmsMouseClicked

    private void radioBtnIdotMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_radioBtnIdotMouseClicked
        frmRequests.setVisible(true);
    }//GEN-LAST:event_radioBtnIdotMouseClicked

    private void imgVehicleMouseDragged(java.awt.event.MouseEvent evt)//GEN-FIRST:event_imgVehicleMouseDragged
    {//GEN-HEADEREND:event_imgVehicleMouseDragged
        /*localPlayer = client.getLocalPlayer();


        Automobile currentCar;

        if( localPlayer != null )
        {
            currentCar = localPlayer.getCurrentCar();

            if( currentCar != null )
            {
                currentCar.setAngle( currentCar.getAngle() - ( float )( dragOrigin.x - evt.getX() ) );
                dragOrigin = evt.getPoint();    // NOTE: Doing this is nice to preserve delta, but we lose original angle info.
            }
        }*/
    }//GEN-LAST:event_imgVehicleMouseDragged

    private void imgVehicleMouseReleased(java.awt.event.MouseEvent evt)//GEN-FIRST:event_imgVehicleMouseReleased
    {//GEN-HEADEREND:event_imgVehicleMouseReleased
        /*localPlayer = client.getLocalPlayer();
        if (localPlayer == null) {
            return;
        }
        
        session = client.getSession();
        if (session == null) {
            return;
        }
        
        Scenario currentScenario = session.getCurrentScenario();
        if (currentScenario == null) {
            return;
        }
        
        Automobile currentCar = localPlayer.getCurrentCar();
        if (currentCar == null) {
            return;
        }

        if ( !currentScenario.detectCollision(currentCar) ) {
            client.moveItem( currentCar, currentCar.getPosition(),
                    currentCar.getPosition(), currentCar.getAngle() );
        }

        // TODO: Check for actual change in car angle.
        dragEndPoint.x = evt.getX();
        dragEndPoint.y = evt.getY();

        this.refreshVehicle();*/
    }//GEN-LAST:event_imgVehicleMouseReleased

    private void imgVehicleMousePressed(java.awt.event.MouseEvent evt)//GEN-FIRST:event_imgVehicleMousePressed
    {//GEN-HEADEREND:event_imgVehicleMousePressed
        /*dragOrigin.x = evt.getX();
        dragOrigin.y = evt.getY();*/
    }//GEN-LAST:event_imgVehicleMousePressed

    /**
     * Adjusts the wheel angle to the left of the local player's current car.
     *
     * @author Tim Pruitt
     *
     * @param evt The event of btnWheelAngleLeft being selected.
     *
     * @see btnWheelAngleRightActionPerformed(java.awt.event.ActionEvent evt)
     */
    private void btnWheelAngleLeftActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnWheelAngleLeftActionPerformed
    {//GEN-HEADEREND:event_btnWheelAngleLeftActionPerformed
        adjustVehicleWheelAngle( -5.0f );
        refreshVehicle();
    }//GEN-LAST:event_btnWheelAngleLeftActionPerformed

    /**
     * Adjusts the wheel angle to the right of the local player's current car.
     *
     * @author Tim Pruitt
     *
     * @param evt The event of btnWheelAngleRight being selected.
     *
     * @see btnWheelAngleLeftActionPerformed(java.awt.event.ActionEvent evt)
     */
    private void btnWheelAngleRightActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnWheelAngleRightActionPerformed
    {//GEN-HEADEREND:event_btnWheelAngleRightActionPerformed
        adjustVehicleWheelAngle( 5.0f );
        refreshVehicle();
    }//GEN-LAST:event_btnWheelAngleRightActionPerformed

    /**
     * Adjusts the wheel angle either direction of the local player's current car.
     *
     * @author Tim Pruitt
     *
     * @param evt The event of imgWheelAngle being dragged across.
     */
    private void imgWheelAngleMouseDragged(java.awt.event.MouseEvent evt)//GEN-FIRST:event_imgWheelAngleMouseDragged
    {//GEN-HEADEREND:event_imgWheelAngleMouseDragged
        adjustVehicleWheelAngle( -( float )( dragOrigin.x - evt.getX() ) );

        dragOrigin.x = evt.getX();
        dragOrigin.y = evt.getY();

        refreshVehicle();
    }//GEN-LAST:event_imgWheelAngleMouseDragged

    private void imgWheelAngleMousePressed(java.awt.event.MouseEvent evt)//GEN-FIRST:event_imgWheelAngleMousePressed
    {//GEN-HEADEREND:event_imgWheelAngleMousePressed
        dragOrigin.x = evt.getX();
        dragOrigin.y = evt.getY();
    }//GEN-LAST:event_imgWheelAngleMousePressed

    private void imgWheelAngleMouseReleased(java.awt.event.MouseEvent evt)//GEN-FIRST:event_imgWheelAngleMouseReleased
    {//GEN-HEADEREND:event_imgWheelAngleMouseReleased
        // Actually send rotation info to client.
        Automobile currentCar;

        localPlayer = client.getLocalPlayer();

        if( localPlayer != null )
        {
            currentCar = localPlayer.getCurrentCar();

            if( currentCar != null )
            {
                // TODO: There is no way to transmit this information via client.
            }
            else {
                this.displayDirections(Feedback.CURRENT_CAR_NULL);
            }
        }

        // TODO: Check for actual change in car wheel angle.

        dragEndPoint.x = evt.getX();
        dragEndPoint.y = evt.getY();
    }//GEN-LAST:event_imgWheelAngleMouseReleased

    /**
     * An item has been selected to be inserted into the scene.
     *
     * @author Tim Pruitt
     *
     * @param evt the pressing of an item label.
     *
     * @param type the type of item selected.
     */
    private void itemLabelMousePressed( MouseEvent evt, String type )
    {
        dragOrigin.x = evt.getX();
        dragOrigin.y = evt.getY();

        localPlayer = client.getLocalPlayer();

        /**
         * The local player's current vehicle.
         *
         * @author Tim Pruitt
         */
        Automobile currentCar = localPlayer.getCurrentCar();
        if( currentCar == null)
        {
            this.displayDirections( Feedback.CURRENT_CAR_NULL );

            return;
        }
        else
        {
            mainFrame.mouseLeftClickedItemReference = currentCar.getFirstItemByType( type );
            mainFrame.gameScenePanel.mousePressed( translateMouseEventForGameScenePanel( ( Component )evt.getSource(), evt ) );

            this.displayDirections( Feedback.SELECTED_AN_ITEM );
        }
    }

    /**
     * The movement of the item being inserted into the scene.
     *
     * @author Tim Pruitt
     *
     * @param evt The dragging of an item.
     * @param type The item type.
     */
    private void itemLabelMouseDragged( MouseEvent evt, String type )
    {
        localPlayer = client.getLocalPlayer();

        if( localPlayer == null )
        {
            System.out.println("item0LabelMouseDragged(***): localPlayer is null. Returning...");
            return;
        }

        /**
         * The local player's current vehicle.
         *
         * @author Tim Pruitt
         */
        Automobile currentCar = localPlayer.getCurrentCar();

        if( currentCar == null )
        {
            System.out.println("item0LabelMouseDragged(***): currentCar is null. Returning...");

            this.displayDirections( Feedback.CURRENT_CAR_NULL );
            return;
        }

        if( evt.getButton() == 0 )
        {
            mainFrame.gameScenePanel.mouseDragged( translateMouseEventForGameScenePanel( ( Component )evt.getSource(), evt ) );

            if( currentCar.getItemCountByType( type ) > 0 ) {
                Item2D tempItem2D = ( Item2D )currentCar.getFirstItemByType( type );
                mainFrame.mouseDraggedItemReference = tempItem2D;

                mainFrame.gameScenePanel.mouseCursorAndItemDelta.x = 0;
                mainFrame.gameScenePanel.mouseCursorAndItemDelta.y = 0;

                this.displayDirections( Feedback.PLACING_ITEM );
            }
        }
    }

    /**
     * The positioning of the item being inserted into the scene.
     *
     * @author Tim Pruitt
     *
     * @param evt The event of releasing the item.
     *
     * @param type The type of item.
     */
    private void itemLabelMouseReleased( MouseEvent evt, String type )
    {
        dragEndPoint.x = evt.getX();
        dragEndPoint.y = evt.getY();
        dragging = false;

        localPlayer = client.getLocalPlayer();

        if (localPlayer != null)
        {
            Automobile currentCar = localPlayer.getCurrentCar();

            if( currentCar != null )
            {
                mainFrame.gameScenePanel.mouseReleased( translateMouseEventForGameScenePanel( ( Component )evt.getSource(), evt ) );

                if( mainFrame.mouseDraggedItemReference != null )
                {
                    // Place this item!
                    int placeX = ( int )( mainFrame.gameScenePanel.mouse.getXDragEnd() / mainFrame.gameScenePanel.videoDisplay.getXScale() );
                    int placeY = ( int )( mainFrame.gameScenePanel.mouse.getYDragEnd() / mainFrame.gameScenePanel.videoDisplay.getYScale() );

                    Item2D placedItem = ( Item2D )mainFrame.mouseDraggedItemReference;
                    placedItem.setPosition( placeX, placeY );

                    if( placedItem.getType().equals( type ) )
                    {
                        //System.out.println("itemLabelMouseReleased(): dragged IN a cone# " + placedItem.getId() );

                        client.sendTransfer( currentCar, placedItem, client.getSession().getCurrentScenario().getWorld() );
                        client.moveItem( placedItem, currentCar.getPosition(), placedItem.getPosition() );

                        this.displayDirections( Feedback.PLACED_ITEM );
                    }
                }
            }
            else {
                this.displayDirections( Feedback.CURRENT_CAR_NULL );
            }
        }
    }
    
    private void item0LabelMousePressed(java.awt.event.MouseEvent evt)//GEN-FIRST:event_item0LabelMousePressed
    {//GEN-HEADEREND:event_item0LabelMousePressed
        itemLabelMousePressed( evt, ServerConstants.ITEM_TYPE_NAME[ServerConstants.CONE] );
    }//GEN-LAST:event_item0LabelMousePressed

    private void item0LabelMouseDragged(java.awt.event.MouseEvent evt)//GEN-FIRST:event_item0LabelMouseDragged
    {//GEN-HEADEREND:event_item0LabelMouseDragged
        itemLabelMouseDragged( evt, ServerConstants.ITEM_TYPE_NAME[ServerConstants.CONE] );
    }//GEN-LAST:event_item0LabelMouseDragged

    private void item0LabelMouseReleased(java.awt.event.MouseEvent evt)//GEN-FIRST:event_item0LabelMouseReleased
    {//GEN-HEADEREND:event_item0LabelMouseReleased
        itemLabelMouseReleased( evt, ServerConstants.ITEM_TYPE_NAME[ServerConstants.CONE] );
    }//GEN-LAST:event_item0LabelMouseReleased

    public java.awt.event.MouseEvent translateMouseEventForGameScenePanel( Component originator, java.awt.event.MouseEvent evt )
    {
        GameScenePanel gameScenePanel = mainFrame.gameScenePanel;

        // Figure out relative translation coordinate distances between this component and the game scene.
        // Then "fake" a mouse event for the game scene panel.
        int componentX = originator.getLocationOnScreen().x;
        int componentY = originator.getLocationOnScreen().y;
        int gameSceneX = gameScenePanel.getLocationOnScreen().x;
        int gameSceneY = gameScenePanel.getLocationOnScreen().y;
        evt.translatePoint( componentX - gameSceneX - 1, componentY - gameSceneY - 1 );

        return( evt );
    }

    private void frmSceneMouseMoved(java.awt.event.MouseEvent evt)//GEN-FIRST:event_frmSceneMouseMoved
    {//GEN-HEADEREND:event_frmSceneMouseMoved
        System.out.println( evt.getX() + ":" + evt.getY() );
    }//GEN-LAST:event_frmSceneMouseMoved

    private void frmSceneMouseDragged(java.awt.event.MouseEvent evt)//GEN-FIRST:event_frmSceneMouseDragged
    {//GEN-HEADEREND:event_frmSceneMouseDragged
        System.out.println( evt.getX() + ":" + evt.getY() );
    }//GEN-LAST:event_frmSceneMouseDragged

    private void btnWheelAngleLeftMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnWheelAngleLeftMousePressed
        adjustVehicleWheelAngle( -5.0f );
        refreshVehicle();
    }//GEN-LAST:event_btnWheelAngleLeftMousePressed

    private void btnWheelAngleRightMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnWheelAngleRightMousePressed
        adjustVehicleWheelAngle( 5.0f );
        refreshVehicle();
    }//GEN-LAST:event_btnWheelAngleRightMousePressed

    private void btnPoliceResponderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPoliceResponderActionPerformed
        playOrStopRole(this.btnPoliceResponder, Role.POLICE);
    }//GEN-LAST:event_btnPoliceResponderActionPerformed

    /**
     * The rotation of the local player's current vehicle is being manipulated
     *  by the use of the sliderRotate component.
     *
     * @author Tim Pruitt
     *
     * @param evt The event of the sliderRotate state being changed.
     */
    private void sliderRotateStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderRotateStateChanged
        localPlayer = client.getLocalPlayer();

        if (localPlayer == null) {
            System.err.println("sliderRotateStateChanged(***): localPlayer " +
                    "is null. Returning...");
            return;
        }

        Automobile currentCar = localPlayer.getCurrentCar();
        if (currentCar == null) {
            System.err.println("sliderRotateStateChanged(***): currentCar " +
                    "is null. Returning...");

            this.displayDirections( Feedback.CURRENT_CAR_NULL );

            return;
        }

        session = client.getSession();
        if (session == null) {
            System.err.println("sliderRotateStateChanged(***): session " +
                    "is null. Returning...");
            return;
        }

        currentCar.setAngle( sliderRotate.getValue() );
    }//GEN-LAST:event_sliderRotateStateChanged

    private void btnReplayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReplayActionPerformed
        client.callReplay();
        txtboxChat.setText("");
    }//GEN-LAST:event_btnReplayActionPerformed

    private void btnSwitchModeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnSwitchModeMouseClicked
        
    }//GEN-LAST:event_btnSwitchModeMouseClicked

    private void frmSceneComponentResized(java.awt.event.ComponentEvent evt)//GEN-FIRST:event_frmSceneComponentResized
    {//GEN-HEADEREND:event_frmSceneComponentResized
        Component c = evt.getComponent();

        client.getGUI().gameScenePanel.getVideoDisplay().setDimensions( c.getWidth(), c.getHeight() );
    }//GEN-LAST:event_frmSceneComponentResized

    /**
     * Switches between editor and play mode.
     *
     * @author Tim Pruitt
     *
     * @param evt The event of btnSwitchMode being selected.
     */
    private void btnSwitchModeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSwitchModeActionPerformed
        session = client.getSession();
        if (session == null) {
            System.err.println("btnSwitchModeActionPerformed(***): " +
                    "session is null. Cannot switch modes. Returning...");
            return;
        }
        
        int oldMode = session.getMode();
        int newMode;

        switch (oldMode) {
            case Session.MODE_EDITOR:
                client.sendPlayModeRequest();
                newMode = Session.MODE_PLAY;
                break;
            case Session.MODE_PLAY:
                client.sendEditorModeRequest();
                newMode = Session.MODE_EDITOR;
                break;
            default:
                newMode = Session.DEFAULT_MODE;
                System.out.println("Could not find the mode. Setting it to default");
        }

        session.setMode(newMode);

        refreshMainScreen();
        setEditables( newMode );
    }//GEN-LAST:event_btnSwitchModeActionPerformed

    private void btnCreateScenarioMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCreateScenarioMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_btnCreateScenarioMouseClicked

    /**
     * Gets rid of the prompt to enter a description since the component
     *  gained focus.
     *
     * @author Tim Pruitt
     *
     * @param evt The event of lblDescription gaining focus.
     */
    private void lblDescriptionFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_lblDescriptionFocusGained
        if (client.getSession().getMode() == Session.MODE_EDITOR &&
                lblDescription.getText().equals( GUIPrompts.SCENARIO_INSERT_TEXT )) {
            lblDescription.setText("");
        }
    }//GEN-LAST:event_lblDescriptionFocusGained

    /**
     * Sets the description of the scenario if a valid scenario name was
     *  input; Sets the text box back to its prompt if otherwise.
     *
     * @author Tim Pruitt
     *
     * @param evt The event of lblDescription losing focus.
     */
    private void lblDescriptionFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_lblDescriptionFocusLost
        String text = lblDescription.getText();

        if (client.getSession().getMode() == Session.MODE_EDITOR) {
            if ( text.isEmpty() ) {
                lblDescription.setText( GUIPrompts.SCENARIO_INSERT_TEXT );
            }
            else if ( !text.equals(GUIPrompts.SCENARIO_INSERT_TEXT) ) {
                client.getSession().getCurrentScenario().setName( text );
                //TODO Tim2Zack - Needs to update this in the file
            }
        }
    }//GEN-LAST:event_lblDescriptionFocusLost

    /**
     * When a scenario is selected, the scenario button needs to be updated.
     *
     * @author Tim Pruitt
     *
     * @param evt The event of listScenarios changing its value.
     */
    private void listScenariosValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_listScenariosValueChanged
        setBtnScenarioEnable();
    }//GEN-LAST:event_listScenariosValueChanged

    private void txtScenarioNameFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtScenarioNameFocusGained
        if (client.getSession().getMode() == Session.MODE_EDITOR) {
            if (txtScenarioName.getText().equals(GUIPrompts.SCENARIO_NAME_INSERT_TEXT)) {
                txtScenarioName.setText( "" );
            }
        }
    }//GEN-LAST:event_txtScenarioNameFocusGained

    private void txtScenarioNameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtScenarioNameFocusLost
        session = client.getSession();
        if (session == null) {
            System.out.println("txtScenarioNameFocusLost(): session is null. returned.");
            return;
        }

        if (session.getMode() == Session.MODE_EDITOR) {
            if (txtScenarioName.getText().isEmpty()) {
                txtScenarioName.setText(GUIPrompts.SCENARIO_NAME_INSERT_TEXT);
            }
            setBtnSaveEnable();
        }
    }//GEN-LAST:event_txtScenarioNameFocusLost

    private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
        String desc = "";
        if ( !lblDescription.getText().equals("") )
            desc = lblDescription.getText();
        client.sendSaveScenario(txtScenarioName.getText(), desc);
    }//GEN-LAST:event_btnSaveActionPerformed

    private void comboRequestItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_comboRequestItemStateChanged
        session = client.getSession();
        if (session == null) {
            System.out.println("comboRequestItemStateChanged(***): " +
                    "session is null. Setting the comboRequest " +
                    "selection back to index 0 and Returning...");
            comboRequest.setSelectedIndex( 0 );
            return;
        }

        localPlayer = client.getLocalPlayer();
        if (localPlayer == null) {
            System.out.println("comboRequestItemStateChanged(***): " +
                    "localPlayer is null. Setting the comboRequest " +
                    "selection back to index 0 and Returning...");
            comboRequest.setSelectedIndex( 0 );
            return;
        }

        if (comboRequest.getSelectedIndex() == 0) {
            btnSendRequest.setEnabled(false);
        }
        else {
            btnSendRequest.setEnabled(true);

            this.displayDirections( Feedback.CLICK_SEND_TO_REQUEST );
        }
    }//GEN-LAST:event_comboRequestItemStateChanged

    private void btnSendRequestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSendRequestActionPerformed
        localPlayer = client.getLocalPlayer();
        if (localPlayer == null) {
            System.err.println("btnSendRequestActionPerformed(***): localPlayer " +
                    "is null. Returning...");
            return;
        }
        
        session = client.getSession();
        if (session == null) {
            System.err.println("btnSendRequestActionPerformed(***): session " +
                    "is null. Returning...");
            return;
        }

        int index = comboRequest.getSelectedIndex() - 1;

        // Send the Request to the Client
        client.sendCreateRequest(ServerConstants.ITEM_TYPE_NAME[index],
                ServerConstants.ITEM_CLASS[index],
                session.getCurrentScenario().getWorld().getId());

        this.displayDirections( Feedback.REQUEST_SENT );

        // Set the combo box to its original state
        comboRequest.setSelectedIndex( 0 );
    }//GEN-LAST:event_btnSendRequestActionPerformed

    private void btnVictimResponderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnVictimResponderActionPerformed
        playOrStopRole(this.btnVictimResponder, Role.VICTIM);
    }//GEN-LAST:event_btnVictimResponderActionPerformed

    private void btnTowResponderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTowResponderActionPerformed
        playOrStopRole(this.btnTowResponder, Role.TOW);
    }//GEN-LAST:event_btnTowResponderActionPerformed

    private void btnIdotResponderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIdotResponderActionPerformed
        playOrStopRole(this.btnIdotResponder, Role.IDOT);
    }//GEN-LAST:event_btnIdotResponderActionPerformed

    private void btnEmsResponderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEmsResponderActionPerformed
        playOrStopRole(this.btnEmsResponder, Role.EMS);
    }//GEN-LAST:event_btnEmsResponderActionPerformed

    private void btnFireResponderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFireResponderActionPerformed
        playOrStopRole(this.btnFireResponder, Role.FIRE);
    }//GEN-LAST:event_btnFireResponderActionPerformed

    private void item1LabelMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_item1LabelMousePressed
        itemLabelMousePressed( evt, ServerConstants.ITEM_TYPE_NAME[ServerConstants.SIGN] );
    }//GEN-LAST:event_item1LabelMousePressed

    private void item1LabelMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_item1LabelMouseDragged
        itemLabelMouseDragged( evt, ServerConstants.ITEM_TYPE_NAME[ServerConstants.SIGN] );
    }//GEN-LAST:event_item1LabelMouseDragged

    private void item1LabelMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_item1LabelMouseReleased
        itemLabelMouseReleased( evt, ServerConstants.ITEM_TYPE_NAME[ServerConstants.SIGN] );
    }//GEN-LAST:event_item1LabelMouseReleased

    private void item2LabelMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_item2LabelMousePressed
        itemLabelMousePressed( evt, ServerConstants.ITEM_TYPE_NAME[ServerConstants.DRUM] );
    }//GEN-LAST:event_item2LabelMousePressed

    private void item2LabelMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_item2LabelMouseDragged
        itemLabelMouseDragged( evt, ServerConstants.ITEM_TYPE_NAME[ServerConstants.DRUM] );
    }//GEN-LAST:event_item2LabelMouseDragged

    private void item2LabelMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_item2LabelMouseReleased
        itemLabelMouseReleased( evt, ServerConstants.ITEM_TYPE_NAME[ServerConstants.DRUM] );
    }//GEN-LAST:event_item2LabelMouseReleased

    private void item3LabelMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_item3LabelMousePressed
        itemLabelMousePressed( evt, ServerConstants.ITEM_TYPE_NAME[ServerConstants.FLARE] );
    }//GEN-LAST:event_item3LabelMousePressed

    private void item3LabelMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_item3LabelMouseDragged
        itemLabelMouseDragged( evt, ServerConstants.ITEM_TYPE_NAME[ServerConstants.FLARE] );
    }//GEN-LAST:event_item3LabelMouseDragged

    private void item3LabelMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_item3LabelMouseReleased
        itemLabelMouseReleased( evt, ServerConstants.ITEM_TYPE_NAME[ServerConstants.FLARE] );
    }//GEN-LAST:event_item3LabelMouseReleased

    private void lblItem0CountKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lblItem0CountKeyPressed
        lblItemCountChanged( evt, ServerConstants.CONE );
    }//GEN-LAST:event_lblItem0CountKeyPressed

    private void lblItem1CountKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lblItem1CountKeyPressed
        lblItemCountChanged( evt, ServerConstants.SIGN );
    }//GEN-LAST:event_lblItem1CountKeyPressed

    private void lblItem2CountKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lblItem2CountKeyPressed
        lblItemCountChanged( evt, ServerConstants.DRUM );
    }//GEN-LAST:event_lblItem2CountKeyPressed

    private void lblItem3CountKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lblItem3CountKeyPressed
        lblItemCountChanged( evt, ServerConstants.FLARE );
    }//GEN-LAST:event_lblItem3CountKeyPressed

    private void sliderRotateMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderRotateMousePressed
        tempAngle = client.getLocalPlayer().getCurrentCar().getAngle();
    }//GEN-LAST:event_sliderRotateMousePressed

    private void sliderRotateMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderRotateMouseReleased
        localPlayer = client.getLocalPlayer();
        if (localPlayer == null) {
            return;
        }

        Automobile currentCar = localPlayer.getCurrentCar();
        if (currentCar == null) {
            return;
        }

        session = client.getSession();
        if (session == null) {
            return;
        }


        if (session.getCurrentScenario().detectCollision( currentCar )) {
            client.moveItem(currentCar, currentCar.getPosition(),
                    currentCar.getPosition(), tempAngle);

            currentCar.setAngle(tempAngle);

            this.displayDirections( Feedback.COLLISION_DURING_ROTATION );
        }
        else {
            client.moveItem( currentCar, currentCar.getPosition(),
                    currentCar.getPosition(), currentCar.getAngle() );

            this.displayDirections( Feedback.ROTATED_CAR );
        }

        refreshVehicle();
    }//GEN-LAST:event_sliderRotateMouseReleased

    private void lblItemCountChanged( java.awt.event.KeyEvent evt, int type )
    {
        // Only act on this when the user has pressed 'ENTER' key.
        if( evt.getKeyCode() != KeyEvent.VK_ENTER )
        {
            this.displayDirections( Feedback.ENTER_ADJUSTS_ITEMS );

            return;
        }

        String typeString = ServerConstants.ITEM_TYPE_NAME[type];
        localPlayer = client.getLocalPlayer();

        if( localPlayer == null )
        {
            System.out.println( "lblItemCountFocusLost(***): localPlayer is null. Returning..." );
            return;
        }

        Automobile currentCar = localPlayer.getCurrentCar();

        if( currentCar == null )
        {
            System.out.println("lblItemCountFocusLost(***): currentCar is null. Returning...");

            this.displayDirections( Feedback.CURRENT_CAR_NULL );

            return;
        }

        JTextField itemCountTextField = ( JTextField )evt.getSource();

        String numberOfTypedItemsString = itemCountTextField.getText();
        int numberOfTypedItems;
        int numberOfCurrentItems = currentCar.getItemCountByType( typeString );

        // Make sure this is actually a number and not something stupid.
        try
        {
            numberOfTypedItems = Integer.parseInt( numberOfTypedItemsString );
        }
        catch( NumberFormatException ex )
        {
            // Invalid text entry (not an integer), reset the code. Abort!
            itemCountTextField.setText( ( ( Integer )numberOfCurrentItems ).toString() );
            return;
        }

        // Determine if the user is requesting more of this type or less.
        int difference = numberOfTypedItems - numberOfCurrentItems;
        if( difference > 0 )
        {
            // User requests more of this type of item.
            
            // Make sure alot (32) isn't added at one time.
            if( difference >= 32 )
            {
                this.displayDirections( Feedback.MAX_ADDED_ITEMS );
                return;
            }

            client.sendCreateRequest( typeString, ServerConstants.ITEM_CLASS[type], currentCar.getId(), 0, 0, difference );

            this.displayDirections( Feedback.ADDED_ITEMS_TO_CAR );
        }
        else
        if( difference < 0 )
        {
            // User requests less of this type of item.
            difference = -difference;   // Get a positive difference (absolute value).
            client.sendRemove( currentCar, typeString, difference );

            this.displayDirections( Feedback.REMOVED_ITEMS_FROM_CAR );
        }
    }

    public void adjustVehicleWheelAngle( float change )
    {
        int MAX_ANGLE = 40;
        Automobile currentCar;

        localPlayer = client.getLocalPlayer();

        if( localPlayer != null )
        {
            currentCar = localPlayer.getCurrentCar();

            if( currentCar != null )
            {
                float newAngle = currentCar.getWheelAngle() + change;
                if (newAngle < -1 * MAX_ANGLE) {
                    newAngle = -1 * MAX_ANGLE;

                    this.displayDirections( Feedback.ADJUSTED_WHEEL_ANGLE_LEFT );
                }
                else if (newAngle > MAX_ANGLE) {
                    newAngle = MAX_ANGLE;

                    this.displayDirections( Feedback.ADJUSTED_WHEEL_ANGLE_RIGHT );
                }
                currentCar.setWheelAngle( newAngle );
            }
            else {
                this.displayDirections( Feedback.CURRENT_CAR_NULL );
            }
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancel;
    javax.swing.JButton btnCreateScenario;
    private javax.swing.JButton btnEmsResponder;
    private javax.swing.JButton btnFinish;
    private javax.swing.JButton btnFireResponder;
    private javax.swing.JButton btnIdotResponder;
    private javax.swing.JButton btnNextVehicle;
    private javax.swing.JButton btnPoliceResponder;
    private javax.swing.JButton btnPreviousVehicle;
    private javax.swing.JButton btnReplay;
    private javax.swing.JButton btnRequestAVehicle;
    private javax.swing.JButton btnRequestMoveCar;
    private javax.swing.JButton btnRequestMoveCone;
    private javax.swing.JButton btnRequestMoveSign;
    private javax.swing.JButton btnSave;
    javax.swing.JButton btnSendMessage;
    private javax.swing.JButton btnSendRequest;
    private javax.swing.JButton btnStartScenario;
    private javax.swing.JButton btnSwitchMode;
    private javax.swing.JButton btnTowResponder;
    private javax.swing.JButton btnVictimResponder;
    private javax.swing.JButton btnWheelAngleLeft;
    private javax.swing.JButton btnWheelAngleRight;
    private javax.swing.ButtonGroup buttonGroupRequestTo;
    private javax.swing.JComboBox comboRequest;
    private javax.swing.JDialog dialogRequest;
    javax.swing.JPanel frmChat;
    javax.swing.JPanel frmHelp;
    javax.swing.JPanel frmItems;
    private javax.swing.JPanel frmRequestTo;
    private javax.swing.JPanel frmRequests;
    javax.swing.JPanel frmResponders;
    javax.swing.JPanel frmScenario;
    javax.swing.JPanel frmScene;
    javax.swing.JPanel frmVehicle;
    javax.swing.JPanel frmWheelAngle;
    javax.swing.JLabel imgVehicle;
    private javax.swing.JLabel imgWheelAngle;
    javax.swing.JLabel item0Label;
    javax.swing.JLabel item1Label;
    javax.swing.JLabel item2Label;
    javax.swing.JLabel item3Label;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    javax.swing.JLabel lblClock;
    private javax.swing.JTextArea lblDescription;
    javax.swing.JTextArea lblDirections;
    private javax.swing.JLabel lblEMS;
    private javax.swing.JLabel lblFire;
    javax.swing.JTextArea lblHelp;
    private javax.swing.JLabel lblIDOT;
    private javax.swing.JTextField lblItem0Count;
    private javax.swing.JLabel lblItem0Name;
    private javax.swing.JTextField lblItem1Count;
    private javax.swing.JLabel lblItem1Name;
    private javax.swing.JTextField lblItem2Count;
    private javax.swing.JLabel lblItem2Name;
    private javax.swing.JTextField lblItem3Count;
    private javax.swing.JLabel lblItem3Name;
    private javax.swing.JLabel lblPolice;
    private javax.swing.JLabel lblResponder1;
    private javax.swing.JLabel lblResponder2;
    private javax.swing.JLabel lblResponder3;
    private javax.swing.JLabel lblResponder4;
    private javax.swing.JLabel lblResponder5;
    private javax.swing.JLabel lblScenarioName;
    private javax.swing.JLabel lblTow;
    private javax.swing.JLabel lblVictim;
    private javax.swing.JLabel lblVictimName;
    private javax.swing.JList listScenarios;
    private javax.swing.JPopupMenu popup;
    private javax.swing.JRadioButton radioBtnEms;
    private javax.swing.JRadioButton radioBtnFire;
    private javax.swing.JRadioButton radioBtnIdot;
    private javax.swing.JRadioButton radioBtnPolice;
    private javax.swing.JSlider sliderRotate;
    private javax.swing.JTextField txtScenarioName;
    javax.swing.JTextField txtTypeMessage;
    javax.swing.JTextArea txtboxChat;
    // End of variables declaration//GEN-END:variables

    /**
     * Displays in the popupRightClick window the vehicle conditions.
     * Ends with a seperator.
     *
     * @author Tim Pruitt
     *
     * @param tempVehicle The vehicle being examined.
     */
    private void displayPopupVehicleConditions(Automobile tempVehicle) {
        displayPopup( ServerConstants.ITEM_DISPLAY_NAME[tempVehicle.getRoleId()] +
                " ( " + tempVehicle.getInstance() + " )");
        popupRightClick.addSeparator();
        
        displayPopup("Vehicle Conditions:");
            if (tempVehicle.isMoveable()) {
                displayPopup(" -- Can Move");
            }
            else {
                displayPopup(" -- Disabled");
            }

            if (tempVehicle.isDamaged()) {
                displayPopup(" -- Damaged");
            }
            else {
                displayPopup(" -- No Damage");
            }

            if (tempVehicle.isOnFire()) {
                displayPopup(" -- On Fire");
            }
            else {
                displayPopup(" -- Not On Fire");
            }

            popupRightClick.addSeparator();
    }

    /**
     * Displays in the popupRightClick window the details if an Item2D was clicked.
     *
     * @author Tim Pruitt
     *
     * @param item The item being described.
     */
    private void displayPopupItemDetails(Item2D item) {
        if ( !item.getType().equals(ServerConstants.ITEM_TYPE_NAME[ServerConstants.WORLD]) ) {
            displayPopup("Details:");
            
            boolean found = false;
            for (int serverIndex = 0; serverIndex < ServerConstants.ITEM_TYPE_NAME.length
                    && !found; serverIndex++) {
                if (item.getType().equals( ServerConstants.ITEM_TYPE_NAME[serverIndex])) {
                    displayPopup(" -- Type: " + ServerConstants.ITEM_DISPLAY_NAME[serverIndex]);
                    found = true;
                }
            }
            if ( !found ) {
                displayPopup(" -- Type: Unknown");
            }
            
            popupRightClick.addSeparator();
        }
    }

    /**
     * Sets the enabling of the btnStartScenario depending on certain conditions.
     *
     * @author Tim Pruitt
     */
    private void setBtnScenarioEnable() {
        session = client.getSession();

        if ( listScenarios.isSelectionEmpty() ) {
            btnStartScenario.setEnabled(false);
        }
        else if ( listScenarios.getSelectedValue().toString().equals
                ( session.getCurrentScenario().getName() ) ) {
            btnStartScenario.setEnabled(false);
        }
        else {
            btnStartScenario.setEnabled(true);
        }
    }

    /**
     * Sets the enabling of buttons in the scenario window.
     * Depend on certain conditions.
     *
     * @author Tim Pruitt
     */
    private void setButtonEnables() {
        setBtnScenarioEnable();
        setBtnSaveEnable();
    }

    /**
     * Sets the enabling of the btnSave.
     *
     * @author Tim Pruitt
     *
     * @see setButtonEnables()
     * @see setBtnScenarioEnable
     */
    private void setBtnSaveEnable() {
        String name = txtScenarioName.getText();
        if (name.isEmpty() || name.equals(GUIPrompts.SCENARIO_NAME_INSERT_TEXT)) {
            btnSave.setEnabled(false);
        }
        else {
            btnSave.setEnabled(true);
        }
    }

    /**
     * Checks to see if the local player's current car is able to put out a fire
     *  in another vehicle.
     *
     * @author Tim Pruitt
     *
     * @param vehicle The vehicle being examined.
     *
     * @return True if it can; False otherwise.
     */
    private boolean canPutOutFire(Automobile vehicle) {
        localPlayer = client.getLocalPlayer();
        if (localPlayer == null) {
            System.err.println("canPutOutFire(vehicle): localPlayer " +
                    "is null. Returning...");
            return false;
        }

        /**
         * The local player's current vehicle.
         *
         * @author Tim Pruitt
         */
        Automobile currentCar = localPlayer.getCurrentCar();
        if (currentCar == null) {
            System.err.println("canPutOutFire(vehicle): currentCar " +
                    "is null. Returning...");
            return false;
        }

        if ( currentCar.getRoleId() == Role.FIRE && vehicle.isOnFire() ) {
            return true;
        }
        else {
            return false;
        }
    }

    /**
     * Displays the options of changing the lights in the right clicking
     *  window.
     *
     * @author Tim Pruitt
     *
     * @param currentLightStatus The current status of the lights.
     */
    private void displayRightClickLights(int currentLightStatus) {
        boolean displayed = false;
        for (int x = 0; x < ServerConstants.TOTAL_LIGHT_STATES; x++) {
            if (x != currentLightStatus) {
                displayPopup( x );
                displayed = true;
            }
        }

        if (displayed) {
            popupRightClick.addSeparator();
        }
    }
}
